ValidationObject
ValidationObject =
object
Properties
caseSensitive?
optionalcaseSensitive?:boolean
Whether to check case sensitivity (i flag)
global?
optionalglobal?:boolean
Whether to check global strings (g flag)
message?
optionalmessage?:string
Error message shown to user if validation fails
Example: "Invalid email format"
multiline?
optionalmultiline?:boolean
Whether to check Multiline strings (m flag)
regExp?
optionalregExp?:string
Should be pure string (not RegExp string)
Example:
// regex for email
regExp: '^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$',
validator?
optionalvalidator?: (value,record,adminForth) => {isValid:boolean;message?:string; } |Promise<{isValid:boolean;message?:string; }> |boolean
Custom validator function.
Example:
validator: async (value) => {
// custom validation logic
return { isValid: true, message: 'Validation passed' }; // or { isValid: false, message: 'Validation failed' }
}
Parameters
| Parameter | Type |
|---|---|
value | any |
record | any |
adminForth | IAdminForth |
Returns
{ isValid: boolean; message?: string; } | Promise<{ isValid: boolean; message?: string; }> | boolean