src/AnnotationGenerator/ConstraintAnnotationGenerator.php
public function generateFieldAnnotations(string $className, string $fieldName): array
    {
        $field = $this->classes[$className]['fields'][$fieldName];

        if ($field['isId']) {
            if ('uuid' === $this->config['id']['generationStrategy']) {
                return ['@Assert\Uuid'];
            }

            return [];
        }

        $asserts = [];
        if (!$field['isArray']) {
            switch ($field['range']) {
                case 'URL':
                    $asserts[] = '@Assert\Url';
                    break;
                case 'Date':
                    $asserts[] = '@Assert\Date';
                    break;
                case 'DateTime':
                    $asserts[] = '@Assert\DateTime';
                    break;
                case 'Time':
                    $asserts[] = '@Assert\Time';
                    break;
            }

            if (isset($field['resource']) && 'email' === $field['resource']->localName()) {
                $asserts[] = '@Assert\Email';
            }

            if (!$asserts && $this->config['validator']['assertType']) {
                $phpType = $this->toPhpType($field);
                if (in_array($phpType, ['boolean', 'float', 'integer', 'string'], true)) {
                    $asserts[] = sprintf('@Assert\Type(type="%s")', $phpType);
                }
            }
        }

        if (!$field['isNullable']) {
            $asserts[] = '@Assert\NotNull';
        }

        if ($field['isEnum']) {
            $assert = sprintf('@Assert\Choice(callback={"%s", "toArray"}', $field['range']);

            if ($field['isArray']) {
                $assert .= ', multiple=true';
            }

            $assert .= ')';

            $asserts[] = $assert;
        }

        return $asserts;
    }
public function generateFieldAnnotations(string $className, string $fieldName): array
    {
        $field = $this->classes[$className]['fields'][$fieldName];

        if ($field['isId']) {
            if ('uuid' === $this->config['id']['generationStrategy']) {
                return ['@Assert\Uuid'];
            }

            return [];
        }

        $asserts = [];
        if (!$field['isArray']) {
            switch ($field['range']) {
                case 'URL':
                    $asserts[] = '@Assert\Url';
                    break;
                case 'Date':
                    $asserts[] = '@Assert\Date';
                    break;
                case 'DateTime':
                    $asserts[] = '@Assert\DateTime';
                    break;
                case 'Time':
                    $asserts[] = '@Assert\Time';
                    break;
            }

            if (isset($field['resource']) && 'email' === $field['resource']->localName()) {
                $asserts[] = '@Assert\Email';
            }

            if (!$asserts && $this->config['validator']['assertType']) {
                $phpType = $this->toPhpType($field);
                if (in_array($phpType, ['boolean', 'float', 'integer', 'string'], true)) {
                    $asserts[] = sprintf('@Assert\Type(type="%s")', $phpType);
                }
            }
        }

        if (!$field['isNullable']) {
            $asserts[] = '@Assert\NotNull';
        }

        if ($field['isEnum']) {
            $assert = sprintf('@Assert\Choice(callback={"%s", "toArray"}', $field['range']);

            if ($field['isArray']) {
                $assert .= ', multiple=true';
            }

            $assert .= ')';

            $asserts[] = $assert;
        }

        return $asserts;
    }
{@inheritdoc}