hasSelections()
const hasSelections: (value, fieldName) => string;
Validates array has at least one selection and no duplicates
Parameters
| Parameter | Type | Description |
|---|---|---|
value | string[] | The array to validate |
fieldName | string | The name of the field for error messages |
Returns
string
Empty string if valid, error message if invalid
Example
hasSelections([], "expertise") // Returns: "Please select at least one expertise."
hasSelections(["Python"], "expertise") // Returns: ""
hasSelections(["Python", "Python"], "expertise") // Returns: "Please remove duplicate expertise selections."
hasSelections(null, "expertise") // Returns: "Please select at least one expertise."