Example #1
0
 public function testValidatorBase()
 {
     $validator = new Validator(__DIR__ . '/../_data/');
     $report = $validator->validate(["shopId" => 1, "serviceType" => "2", "order" => ["number" => "VAL0001", "date" => "2014-03-01"], "from" => ["name" => "YuTIn", "address" => "Taiwan, Taipei", "phone" => "0963066000"], "to" => ["name" => "YuTIn", "address" => "Taiwan, Taipei", "phone" => "0963066000"]], 'schema');
     Debug::debug($validator->getMessage());
     $this->assertTrue($report);
 }
Example #2
0
 /**
  * Use JSON Schema validation data
  * 
  * @param mixed  $data   data
  * @param string $schema json schema
  * 
  * @return mixed
  */
 protected function validate($data, $schema)
 {
     $validator = new Validator($this->validatorDir);
     $report = $validator->validate($data, $schema);
     if ($validator->getMessage()) {
         array_push($this->errorMessage, $validator->getMessage());
     }
     return $report;
 }