Exemple #1
0
 public function validate($value)
 {
     parent::validate($value);
     if (!is_a($value, $this->type, false)) {
         throw new ValidationException(sprintf('Object must be of type %s.', $this->type));
     }
     return true;
 }
 /**
  * JsonValidator constructor.
  * @param array $ruleSet set of rules for JSON.
  */
 public function __construct(array $ruleSet)
 {
     parent::__construct(TypeOf::TYPE_ARRAY);
     $this->ruleSet = $ruleSet;
 }
 /**
  * @dataProvider objectFailureValuesProvider
  * @expectedException \Alien\Constraint\Exception\ValidationException
  */
 public function testObjectFailure($nonObject)
 {
     $constraint = new Type(Type::TYPE_OBJECT);
     $constraint->validate($nonObject);
 }