public getMessages ( string $item = null ) : array | ||
$item | string | key of the messages array (eg: 'password', 'addresses[0][line_1]') |
리턴 | array |
public function validate($rules = null) { $validator = new Validator(); foreach ($this->rules as $rule) { $fields = explode(',', str_replace(' ', '', $rule[0])); foreach ($fields as $field) { count($rule) == 4 ? $validator->add($field, $rule[1], $rule[2], \I18n::translate($rule[3]), $this->label($field)) : $validator->add($field, $rule[1], [], \I18n::translate($rule[2]), $this->label($field)); } } if (!$validator->validate($this->getAttributes())) { $messages = $validator->getMessages(); foreach ($messages as $message) { foreach ($message as $error) { $this->errors[] = (string) $error; } } return false; } return true; }
/** * {@inheritdoc} */ public function errors() { return $this->validator->getMessages(); }