* * [ '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:----lj0rUbzT9h16Ze6fKkedwWu3YoTs9ZJH8XNIyRor0uYnJTbM0d8Y0oqU3DYJPxj4kuQAWyaCEq8My7uZrtxYhkPreK4uhHAHQx4pytNG2Fyh1j1FR1q4ZxwIJbbVzEPrY+uhr8whMKXK/bJ62vtnD6uR2H+bdxfYkZsELt2zBkU99NBGcXcH4iY7/yafqbXwob8Axomap78Samy40MxNRv1BYDMUD2vuXPPetWAQHeme9O2x2pCZI3Phaa8pezvmiGbG5EyAPJSLEZQfq137/RZsPxE4XLEglzG4Laa7UvQJGC4lB3yfC1lWE4JbsZzjE/9j20rt4bVQJy0hFGmRwowrQnXONAaiMJSRwSdUsqkYGiRcPcs7O3YnxBUDm7RfkoBrretj7KYY0PjfazFSgKkeIOgArW6wXaZJ6ZkEkd5WL4g8Z0MoOL11bvQNc57VGYJsqvbWx6Yv/22f5VSjO02dwUwXLenjYi3A4/IZnWOUx3V9oYSGgKWFKHljTAXyJcr/hl0+6k3Hdy/KhIjTHxylBALwzZQe/QYN0b4LV2EAPpBev+ex1tpE7z0R/B9wDj3jAXeCSzUGekkL5/TMEVrh2X5nA5lSgmgtB+Wy0KsX+75BKjACuDmMz4PVAoNKo0aKbsNvZaf2V8Yb+jebWCnvQVy0iRXVEJMK+2rVOgY=----ATTACHMENT:----OTM2NjQ0OTM4Mjc3NDYyNSA1NjMyNjA0MjUyNTIxNDk1IDc3NTA0MDE5MjI1NzM3NzE=