Rules in contact form / Validators

Hi there,

based on Bastians contactform example (https://gist.github.com/bastianallgeier/c396df7923848912393d) I want to add a rule checking if some variable is similar to another. For example if to fields containing mailadresses are the same.

Based on the cheat sheet validators (https://getkirby.com/docs/cheatsheet/validators/same) I tried to do something with ::same or ::equals but it didn’t work out.

Is there a validator I can use like

$rules = array(
‘email’ => array(‘required’, ‘equals’ => $value2),

or am I missing something in the docs?

Thanks very much!
Tobias

same was correct, so it should be:

'email' => array('required', 'same' => $value2),

However you need to make sure that $value2 actually contains the value you want to check for, e.g. by using $value2 = $data['emailconfirm'];.

1 Like

Thank you very much!

Is this documented some where, and are there other validators as well?

Well, you linked to the documentation in the cheat sheet. It might be that some are currently missing, but we are currently updating the cheat sheet.

Also see the entry for the invalid() helper.

1 Like