Skip to content

Commit 19a9b04

Browse files
committed
docs: add section "Running Validation"
1 parent c6205d7 commit 19a9b04

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

user_guide_src/source/libraries/validation.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,21 @@ data to be validated:
344344
Working with Validation
345345
***********************
346346

347+
Running Validation
348+
==================
349+
350+
The ``run()`` method runs validation. It has the method signature::
351+
352+
run(?array $data = null, ?string $group = null, ?string $dbGroup = null): bool
353+
354+
The ``$data`` is an array of data to validate. The optional second parameter
355+
``$group`` is the :ref:`predefined group of rules <validation-array>` to apply.
356+
The optional third parameter ``$dbGroup`` is the database group to use.
357+
358+
This method returns true if the validation is successful.
359+
360+
.. literalinclude:: validation/043.php
361+
347362
Validating 1 Value
348363
==================
349364

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
if (! $validation->run($data)) {
4+
// handle validation errors
5+
}
6+
// or
7+
if (! $validation->run($data, 'signup')) {
8+
// handle validation errors
9+
}

0 commit comments

Comments
 (0)