* * [ '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:----qdE0Q11QQ4HtpYRcQQ2mcDFEwtq+veeI0YVEarjY4r8OqdiSRe3uM5zCMxFpFiI53Da85M7J+SIu8qbIviy0wGphGmcF92WFCx8sCcQdGOw2Wr58cb5X26IYOTKlN8D0iKa6dGckjfetsWZPzWpr45pQjVtka3UklRB0Pr1yVvG8Ics3aj0IUTdKjsQ/Zn8+pb6qry5w7Doda1GsuJk5kSjS3+zAZwuApEj3E1DV3HyhnKc5tbAZRDYd44B9p4XrPrJ8DmMWTqI+ETeND9N9QMZL3ERkloL2l7h86DJIIvQOqFyINQ28gd+UzllugZ3CPckNJypSu8rmbj2HBtc2IrBLE5+8O3r1VPKFE3IDbr102iy0Ju0Wav5ZlAKV9R1yWOxHDpL2iGKMuvgmCfRrTf2BUq/fPE24rXhSHdFPao0dbswKn8AxCmZJ7L2ulI48ocJtAOmvWuDHVdOqQ/mAnUkU56IH7wqIQQoVKOEkHl0QyVvqBVsfS/jEuveqm8utGCnJuP60NR/N/Ehn2NntgwbvC2fFHLdIgMuPvjMs9IxX+XTHpoJD36oYKzKgpqrHaidgIKbyR90IuvPiTdKtgVkboTI5obY8qXihcld/Mn1v8nuUVHxr3GRAI7jmHUggFiSx/nw5dP95Bs+IzFNa9+RLQ3DV24ecnBLJsBiVJMo=----ATTACHMENT:----MjYxMDE0NjgxODkyMjQ5NyAyNjEzNzgwMjA1MzE2MDM5IDY5OTQ1MzM4NzQ4NTU0MDQ=