Skip to content

Validator generation automatically enforces 'NotEmpty()' for non-nullable strings #688

@David1Socha

Description

@David1Socha

I'm dealing with a codebase where some entities have strings that are non-nullable, but expect String.Empty to be set under certain conditions. Currently, when using the EntityFrameworkCore.Generator tool with validator generation enabled, NotEmpty() validators are added to all non-null string fields. However, this seems slightly overbroad, since empty string is a valid input for the database, and may be a desired input.

Would it be possible to either change the default validator generated for non-nullable strings from NotEmpty to NotNull, or to add a boolean option to the validators configuration section that changes the default validator generated for non-nullable strings from NotEmpty to NotNull?

If either such change would be acceptable, I'd be happy to submit such a PR. Thanks for creating this helpful library!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions