You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The identityCard rule currently only accepts verifying the Polish Identity Card numbers.
I added my own rule.
But... I couldn't add the classes to my own namespace(MyApp), so I added them to composer.json to load them.
# src/Libraries/Validation/Exceptions/Locale/XxIdentityCardException.php<?phpnamespaceRespect\Validation\Exceptions\Locale;
useRespect\Validation\Exceptions\ValidationException;
classXxIdentityCardExceptionextendsValidationException
{
/** * @var array */publicstatic$defaultTemplates = [
self::MODE_DEFAULT => [
self::STANDARD => '{{name}} must be a valid Xx Identity Card number',
],
self::MODE_NEGATIVE => [
self::STANDARD => '{{name}} must not be a valid Xx Identity Card number',
],
];
}
if i understood correctly, you just want to add a new rule. on version 2.2.x, i'm doin' this in order to create "extra" rules: \Respect\Validation\Factory::setDefaultInstance((new \Respect\Validation\Factory())->withRuleNamespace('\\Validators\\Respect\\Rules')->withExceptionNamespace('\\Validators\\Respect\\Exceptions'));
Validators\Respect\Rules -> the directory where the rule class will be Validators\Respect\Exceptions -> the directory where the exception class will be
$className = __NAMESPACE__.'\\Locale\\'.$shortName;
if (!class_exists($className)) {
thrownewComponentException(sprintf('There is no support for identity cards from "%s"', $countryCode));
}
Alternatively, I could create my own IdentityCard class and define the Locale classes within my own namespace.
v::identityCard(string $countryCode)
https://respect-validation.readthedocs.io/en/1.1/rules/IdentityCard/
The identityCard rule currently only accepts verifying the Polish Identity Card numbers.
I added my own rule.
But... I couldn't add the classes to my own namespace(MyApp), so I added them to composer.json to load them.
Is my approach correct?
Then
composer dump-autoload
The text was updated successfully, but these errors were encountered: