If you are using a framework other than the following, then you may need to implement the presence validator

  • Laravel
  • Rangine
  • ThinkPHP

Implementation of presence verifier

When you use Exists and Unique rules, you will need to use the presence verifier, this time you need to implement the Itwmw\Validation\Support\Interfaces\PresenceVerifierInterface interface

class PresenceVerifier implements PresenceVerifierInterface{}

ValidateConfig::instance()->setPresenceVerifier(new PresenceVerifier());

Provide the validator factory with the required

  • Provision of translator setTranslator 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 Itwmw\App\Model\Validate\Rules\AlphaDash,Then the prefixes you need to provide are Itwmw\App\Model\Validate\Rules

ValidateConfig::instance()->setRulesPath('Itwmw\\App\\Model\\Validate\\Rules\\');