protected function fieldConstraintsToRules($field, AbstractData $data)
    {
        $rules = [];
        if ($this->definition->getField($field, 'required', false)) {
            $rules[] = ['required'];
        }
        if ($this->definition->getField($field, 'unique', false)) {
            $rules[] = ['unique', $data, $this->entity, $field];
        }
        return $rules;
    }