/**
* Method that validates fields of the entity based on its restrictions
*/
protected function validateFields()
{
$validator = new Validator($this->data, [], 'en');
//@todo: if use external i18n library?
if ($this->action == 'new') {
$validator->rules(array_merge($this->rulesNew, $this->rulesGlobal));
} else {
$validator->rules(array_merge($this->rulesModify, $this->rulesGlobal));
}
if (!$validator->validate()) {
$this->errors = array_merge($this->errors, $validator->errors());
}
}