NJFInputValidationRules
export interface NJFInputValidationRules {
allowEmpty: boolean;
inputType: NJFInputTypeEnum;
errorMessage?: string;
minLength?: number;
maxLength?: number;
forbiddenCharacters?: string[];
customRegex?: string;
realtimeCustomRegex?: string;
matchValueWith?: string;
numberOperations?: {
operation: NJFMathOperationEnum;
number: number;
}[];
}
Property | Type | Description |
---|---|---|
allowEmpty | boolean* | Whether the field can be empty or not. |
inputType | NJFInputTypeEnum* | Input type. |
errorMessage | string? | Will replace the automatically generated messages from the validation rules function. |
minLength | number? | Minimum character length. |
maxLength | number? | Maximum character length. |
forbiddenCharacters | Array of string? | Any character in that array will not be allowed in the field. |
customRegex | string? | Custom regular expression that will trigger an error for every character that triggers the expression. |
realtimeCustomRegex | string? | Custom regular expression that will prevent any of character that triggers the expression from being typed in the field (will not trigger an error). Better used in combination with customRegex. |
matchValueWith | string? | ID of the field that this field's value needs to match in order to pass validation. A common use case is for password and repeat password fields. |
numberOperations | Array of Custom? | Used only for number fields, array of mathematical operations that needs to be satisfied for the validation to pass. For example number of guests needs to be greater than 5 and less or equal than 8. |
* = Required
? = Optional
numberOperations
Property | Type | Description |
---|---|---|
operation | NJFMathOperationEnum* | |
number | number* |