Although writing a custom validator is easy with Bee Form, the package "bee-form-validators" does include a number of basic validators for your convenience
Name: "required"
This validator makes sure the field's value can not be null or empty
import {required} from "bee-form-validators";
const formConfig = ({
"name": [required],
});
Name: "email"
This validator makes sure the field's value is of email format. Note that it will accept null or empty values (actually all validators except for required validator will accept null/empty values unless stated other wise)
import {email} from "bee-form-validators";
const formConfig = ({
"email": [email],
});
Name: "phone"
This validator makes sure the field's value is of phone format.
import {phone} from "bee-form-validators";
const formConfig = ({
"phone": [phone],
});
Name: "humanName"
This validator makes sure the field's value is of human name format.
import {humanName} from "bee-form-validators";
const formConfig = ({
"first_name": [humanName],
});
Name: "maxLength"
This validator makes sure the field's value will not exceed given length.
import {maxLength} from "bee-form-validators";
const formConfig = ({
"code": [maxLength(3)],
});
Name: "either"
This validator makes sure the field's value will be either of given values.
import {either} from "bee-form-validators";
const formConfig = ({
"sex": [either("male", "female", "gay", "lesbian")],
});