Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StringField validate logic makes all string fields required regardless of required flag value #236

Open
clockard opened this issue Apr 24, 2019 · 2 comments

Comments

@clockard
Copy link
Member

When using the StringField as part of a new field class the underlying validate will cause the string field to always be required. StringField calls it super.validate which checks the required flag but the StringField validate then goes on to check if the field value is empty and adds an exception if it is without checking if it is required or not.

@avalexxx
Copy link
Contributor

Whenever a value is provided for a field, it is validated, not just when marked required. This is to ensure optional fields are still validated through the same validation flow. If the client doesn't want a field to be validated, they should not be specifying the field in the request.

@avalexxx
Copy link
Contributor

A majority of the time, an empty string is an invalid input. If there is a use case where an empty string should be a valid value, I would prefer to have a field extend StringField and override validate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants