title: How to create a custom validation rule in cake 3
body: <p>I am working on Cake 3. I want to create a custom validation-rule.
  I want to check if the field 'password' is equal to the 'confirm_password' field.</p>
  
  <p>This is my code:</p>
  
  <pre><code> public function validationDefault(Validator $validator) {
          $validator
                  -&gt;add('id', 'valid', ['rule' =&gt; 'numeric'])
                  -&gt;allowEmpty('id', 'create')
                  -&gt;add('email', 'valid', ['rule' =&gt; 'email'])
                  -&gt;requirePresence('email', 'create')
                  -&gt;notEmpty('email')
                  -&gt;add('email', 'unique', ['rule' =&gt; 'validateUnique', 'provider' =&gt; 'table'])
                  -&gt;requirePresence('password', 'create')
                  -&gt;notEmpty('password')
                  -&gt;notEmpty('confirm_password')
                  -&gt;add('confirm_password', 'custom', [
                      'rule' =&gt; function($value, $context) {
                          if ($value !== $context['data']['password']) {
                              return false;
                          }
                          return false;
                      },
                      'message' =&gt; 'The passwords are not equal',
          ]);
  
          return $validator;
      }
  </code></pre>
  
  <p>When I try to 'fail' the form-submit, the code saves, and I get no error.</p>
  
  <p>I read <a href="http://book.cakephp.org/3.0/en/core-libraries/validation.html#custom-validation-rules">http://book.cakephp.org/3.0/en/core-libraries/validation.html#custom-validation-rules</a> but didn't help.... Anybody?</p>
  
  <p>Thanks!</p>