Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions en/core-libraries/validation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -168,16 +168,16 @@ Validator instances come with a 'default' provider setup automatically. The
default provider is mapped to the :php:class:`~Cake\\Validation\\Validation`
class. This makes it simple to use the methods on that class as validation
rules. When using Validators and the ORM together, additional providers are
configured for the table and entity objects. You can use the ``provider()``
configured for the table and entity objects. You can use the ``setProvider()``
method to add any additional providers your application needs::

$validator = new Validator();

// Use an object instance.
$validator->provider('custom', $myObject);
$validator->setProvider('custom', $myObject);

// Use a class name. Methods must be static.
$validator->provider('custom', 'App\Model\Validation');
$validator->setProvider('custom', 'App\Model\Validation');

Validation providers can be objects, or class names. If a class name is used the
methods must be static. To use a provider other than 'default', be sure to set
Expand All @@ -203,7 +203,7 @@ model fields, depending on a country, ie::
public function validationDefault(Validator $validator)
{
// add the provider to the validator
$validator->provider('fr', 'Localized\Validation\FrValidation');
$validator->setProvider('fr', 'Localized\Validation\FrValidation');
// use the provider in a field validation rule
$validator->add('phoneField', 'myCustomRuleNameForPhone', [
'rule' => 'phone',
Expand Down