| 1 | <?php namespace Usman\Guardian\Validators; |
||
| 7 | abstract class BaseValidator implements BaseValidatorInterface { |
||
| 8 | |||
| 9 | /** |
||
| 10 | * Represents the data to be validated. |
||
| 11 | * |
||
| 12 | * @var array |
||
| 13 | */ |
||
| 14 | protected $fields; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Rules for data validation |
||
| 18 | * |
||
| 19 | * @var array |
||
| 20 | */ |
||
| 21 | protected $rules; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * The validator instance. |
||
| 25 | * |
||
| 26 | * @var Factory |
||
| 27 | */ |
||
| 28 | protected $validator; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Creates an instance of the class. |
||
| 32 | * |
||
| 33 | * @param Factory $validator |
||
| 34 | */ |
||
| 35 | public function __construct(Factory $validator) |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Validates the data. |
||
| 42 | * |
||
| 43 | * @param string $type type of validation create/update. |
||
| 44 | * @throws ValidationException |
||
| 45 | * @return boolean |
||
| 46 | */ |
||
| 47 | public function validate($type) |
||
| 60 | |||
| 61 | /** |
||
| 62 | * Sets the fields to be validated. |
||
| 63 | * |
||
| 64 | * @param array $fields |
||
| 65 | */ |
||
| 66 | public function setFields(array $fields) |
||
| 71 | |||
| 72 | /** |
||
| 73 | * Adds additional rules for data validation. |
||
| 74 | * |
||
| 75 | * @param string $type |
||
| 76 | * @param string $field |
||
| 77 | * @param string $rule |
||
| 78 | */ |
||
| 79 | public function addRule($type, $field, $rule) |
||
| 83 | |||
| 84 | } |