Viewing file: LaravelValidator.php (1.1 KB) -rw-rw-rw- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php namespace Prettus\Validator;
use Illuminate\Contracts\Validation\Factory;
/** * Class LaravelValidator * @package Prettus\Validator * @author Anderson Andrade <contato@andersonandra.de> */ class LaravelValidator extends AbstractValidator { /** * Validator * * @var \Illuminate\Validation\Factory */ protected $validator;
/** * Construct * * @param \Illuminate\Contracts\Validation\Factory $validator */ public function __construct(Factory $validator) { $this->validator = $validator; }
/** * Pass the data and the rules to the validator * * @param string $action * @return bool */ public function passes($action = null) { $rules = $this->getRules($action); $messages = $this->getMessages(); $attributes = $this->getAttributes(); $validator = $this->validator->make($this->data, $rules, $messages, $attributes);
if ($validator->fails()) { $this->errors = $validator->messages(); return false; }
return true; } }
|