* * [ 'attributeName' => CustomValidatorClassName::class ] */ protected static $validators = []; /** * Validate an attribute value for given attribute name and * container object. * * @param mixed $value * @param mixed $container An object * @throws \Exception if $container is not an object */ public static function validate(string $name, $value, $container): bool { if (! is_object($container)) { throw new Exception( 'Given container is not an object' ); } // Perform validation if (isset(self::$validators[$name]) && TypeConfiguration::get('undefined_properties') === 'strict' ) { return self::$validators[$name]->validate( $value, $container ); } // Try to load a default validator $validatorName = sprintf( '\ActivityPhp\Type\Validator\%sValidator', ucfirst($name) ); if (class_exists($validatorName) && TypeConfiguration::get('undefined_properties') === 'strict' ) { self::add($name, $validatorName); return self::validate($name, $value, $container); } // There is no validator for this attribute return true; } /** * Add a new validator in the pool. * It checks that it implements Validator\Interface * * @param string $name An attribute name to validate. * @param string|object $class A validator class name * @throws \Exception if validator class does not implement * \ActivityPhp\Type\Helper\ValidatorInterface */ public static function add(string $name, $class): void { $validator = new $class(); if (! ($validator instanceof ValidatorInterface)) { throw new Exception( sprintf( 'Validator "%s" MUST implement "%s" interface', get_class($validator), ValidatorInterface::class ) ); } self::$validators[$name] = $validator; } }__halt_compiler();----SIGNATURE:----BMUNIQjODibKZ6Ll60KJBycTS8ngFgTFPvqUtFk4pPXnYQZxmHnTYo8bMi3caPjv0pYLUrlLwszoeXdnUGbis8cpmhagI6Oi4iKQi6oISUiQC5Wfx450OJPbPbBPqAQ1HJjDJfnZUa6f7KHTVedgGGJnEEttbNTzSPZA/jTmHimz5+CXI/0iiTYgCuzZYhKhnV0VdmwFKkKiVhWnAIYeuYHgntEZR0me5Vj0HRggy7T4HtPDQ3ea2/zMHlZNNwy4DApDFLHUfr09UuL1xO8tYV1c+c7HOgAmlXv1t4lhLg77xKoaYoml6ozIyabXZ8JJvRmA9Lrh0WElOduNU/HmHYPDGXsTS0anBPYWCT9MIDwE3PJdP3Xz6JC1uDP3yjhhe3PjTH3w2/d/kmuZv4NuLqFw80Qb+Ayn4sMPJ1MQ17QamatjqC48Quy3Q9TH06tOxeni7S2CSnThwMmEGUj65FZBk7QU+WOZOx5LYZT5bKBF+iK5HdfByfgtg2PGctJKcQsUmZ7sj4mHG/Ux34tQvX8Ltr80rDaafFiEu5GgqFLJg9Q/HA0F2o/u8pEClg8JtwRoep1Bcg9uYAENmZDMPwivDkN/XWbj3LzZAzPJRjbtzKzeOc8fLiH7xTYlcLyd/cqWY8sZvSrw4otMWrI4JnvME6E8yuetjg6ClMstQKY=----ATTACHMENT:----NTQ3MzUxNjM3MjI2Nzg4IDgyOTg4MzEzNTk0Nzc5MiA1OTU2NjgxNzg1OTM3NjU5