Skip to content

Commit

Permalink
docs: add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Dec 11, 2022
1 parent de037cb commit ca19a98
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions user_guide_src/source/libraries/validation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,10 @@ You must set the error message for the closure rule.
When you specify the error message, set the array key for the closure rule.
In the above code, the ``required`` rule has the key ``0``, and the closure has ``1``.

Or you can use the following parameters:

.. literalinclude:: validation/041.php

Available Rules
***************

Expand Down
18 changes: 18 additions & 0 deletions user_guide_src/source/libraries/validation/041.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

$validation->setRules(
[
'foo' => [
'required',
static function ($value, $data, &$error, $field) {
if ((int) $value % 2 === 0) {
return true;
}

$error = 'The value is not even.';

return false;
},
],
],
);

0 comments on commit ca19a98

Please sign in to comment.