A form composed of fields, each can be validated by provided list of constraints.
type: boolean
default: false
Usually, if you submit extra fields that aren't configured in your form, you'll get a
"This form should not contain extra fields."
validation error.
You can silence this validation error by enabling the extra_fields
option on the form.
type: string
default: This form should not contain extra fields.
This is the validation error message that's used if the submitted form data contains one or more fields that are not part of the form definition.
Add field specification.
Parameter | Type | Description |
---|---|---|
field | string | The validation filed name |
constants | array | List of constraints that should be assigned to the field |
options | object | Extra options related to the Field. Will be passed to each constraint |
Return: current Form
Execute form validation.
Parameter | Type | Description |
---|---|---|
data | object | The current form data |
options | object | Extra options related to the validation flow. Will be passed to each constraint |
Return: object with validation errors.
Return object with current loaded data. If data transformers assigned to the form of field, then it will be modified data object.
Return: object with form data.
Return object associated with provided field name.
Parameter | Type | Description |
---|---|---|
name | string | The field name |
Return: Field or undefined
.
Add a transformer to the current form.
Parameter | Type | Description |
---|---|---|
transformer | function | This function will be executed before form validation |
Return: current Form
Add a reverse transformer to the current form.
Parameter | Type | Description |
---|---|---|
transformer | function | This function will be executed after form validation |
Return: current Form
The signature for addTransformer(transformer)
and addReverseTransformer(transformer)
methods
const transformer = function(data, options) {
// hack, hack, hack ...
return data;
}
Parameter | Type | Description |
---|---|---|
data | object | The current form data |
options | object | The current form validation options |
Return: modified form data object