Пример #1
0
 public function createValidator(Form $form)
 {
     // Look if a explicit validator creating method was created
     if (method_exists($form, 'createValidator')) {
         $validator = $form->createValidator();
         if ($validator instanceof Validator) {
             return $validator;
         }
         if ($validator instanceof LaravelValidator) {
             $formValidator = new Validator($form);
             $formValidator->setSrcValidator($validator);
             return $formValidator;
         }
     } elseif (method_exists($form, 'validationRules')) {
         $rules = $form->validationRules();
         $validator = new Validator($form);
         $validator->setRules($rules);
         return $validator;
     } elseif (property_exists($form, 'validationRules')) {
         $validator = new Validator($form);
         $validator->setRules($form->validationRules);
         return $validator;
     }
     return new Validator($form);
 }
Пример #2
0
 public function getSrcValidator()
 {
     if (!$this->srcValidator) {
         $srcValidator = LaravelFactory::make([], $this->getRules());
         $this->setSrcValidator($srcValidator);
     }
     return $this->srcValidator;
 }