Configuration Validator Factory

You can choose either of the following two ways

Provide validator factory

If your framework is not Laravel or Rangine, but uses the extension illuminate/validation in your project, you can set up the validator factory directly

ValidateConfig::instance()->setFactory($factory);

// Method prototype is:
public function setFactory(Factory $factory): ValidateConfig
1
2
3
4

Provide the validator factory with the required

  • Provision of translator setTranslator
  • Provision of container setContainer Optional
  • Provide implementation of presence verifier setPresenceVerifier Optional

Validation rules that require manipulation of the database, such as exists, cannot be used if a presence verifier is not provided.

Configure custom rule class paths

In order for the validator to automatically discover the custom rule class, the namespace prefix of the custom rule needs to be configured, e.g. the full namespace of your rule is W7\App\Model\Validate\Rules\AlphaDash,Then the prefixes you need to provide are W7\App\Model\Validate\Rules

ValidateConfig::instance()->setRulesPath('W7\\App\\Model\\Validate\\Rules\\');
1
Last Updated: 10/13/2021, 2:39:38 PM