public function validate(string $method = 'save'): array
    {
        $errors = [];
        foreach ($this->getValidators()[$method] ?? [] as $field => $validator) {
            try {
                $validator->setName($field)->assert($this->get($field));
            } catch (NestedValidationException $e) {
                $errors[$field] = $e->getMessages();
            }
        }

        return $errors;
    }
public function validate(string $method = 'save'): array
    {
        $errors = [];
        foreach ($this->getValidators()[$method] ?? [] as $field => $validator) {
            try {
                $validator->setName($field)->assert($this->get($field));
            } catch (NestedValidationException $e) {
                $errors[$field] = $e->getMessages();
            }
        }

        return $errors;
    }
public function validate ( string $ method = 'save' ) : array { $ errors = [ ] ; foreach ( $ this -> getValidators ( ) [ $ method ] ?? [ ] as $ field => $ validator ) { try { $ validator -> setName ( $ field ) -> assert ( $ this -> get ( $ field ) ) ; } catch ( NestedValidationException $ e ) { $ errors [ $ field ] = $ e -> getMessages ( ) ; } } return $ errors ; }
Validate entity data.

@param string $method Validation for method, default: save

@return array [['field' => 'error message']]
Validate entity data .