protected function isValidUnique($value, AbstractData $data, Entity $entity, $field, $type)
    {
        $params          = [$field => $type === 'reference' ? $value['id'] : $value];
        $paramsOperators = [$field => '='];
        if ($entity->get('id') !== null) {
            $params['id']          = $entity->get('id');
            $paramsOperators['id'] = '!=';
        }
        $amount = intval($data->countBy($data->getDefinition()->getTable(), $params, $paramsOperators, true));
        return $amount == 0;
    }