Skip to content

Field value validators

Jesús Alonso Abad edited this page Jun 19, 2018 · 1 revision

Every field value validator should extend FormValidator::AbstractFieldValueValidator or one of its subclasses.

The default field value validators

  • FormValidator::FieldValueValidators::NonEmpty: Validates that the field has a value. Can optionally receive the following parameters:

    • trim_spaces: If set to 1, will trim the spaces of the value, so only-whitespace values will be considered as empty as well. If omitted, will be set to 0 (i.e., allowing spaces-only values)
  • FormValidator::FieldValueValidators::IsNumeric: Validates that the field value is a number. Can optionally receive the following parameters:

    • integer_only: If set to 1, will only accept integer values. If omitted, it's set to 0 by default (i.e., accepts decimal values).
    • positive_only: If set to 1, will only accept values greater or equal to zero. If omitted, it's set to 0 by default (i.e., accepts negative numbers).
Clone this wiki locally