コード例 #1
0
ファイル: DataModel.php プロジェクト: domraider/rxnet
 /**
  * Validation sugar to use on a flatMap
  * Validate against schemas of the constructors
  * @return \Closure
  */
 public function validate()
 {
     return function ($payload) {
         // validate
         foreach ($this->schemas as $schema) {
             $validator = new Validator($payload, $schema);
             foreach ($this->formatExtensions as $format => $class) {
                 $validator->registerFormatExtension($format, new $class());
             }
             if ($validator->fails()) {
                 foreach ($validator->errors() as $error) {
                     /* @var ValidationError $error */
                     print_r($error->toArray());
                 }
             }
         }
     };
 }