Skip to content

Kirby 3.5.7.1

Validators

Validators can be used in your code to run common validations against any kind of data. They are also available in Panel fields to extend form validation.

Examples

To give you an idea of what you can do with validators, here are some examples:

Check if a string contains only alpha-numeric characters

if (V::alphanum('abc123')) {
  echo 'Yay, valid!';
}

Check if a value is contained in an array of values

$animals = ['tiger', 'lion', 'elephant', 'cameleon'];

if (!V::in('cuddly toy', $animals)) {
  echo 'Not an animal';
}

Checks if the given value is a valid email adress

if (V::email('you@yourdomain.com')) {
  echo 'Yay, valid!';
}