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

Model state should display either 1st or all invalid fields #302

Open
KishB opened this issue Jan 12, 2023 · 0 comments
Open

Model state should display either 1st or all invalid fields #302

KishB opened this issue Jan 12, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@KishB
Copy link

KishB commented Jan 12, 2023

Issue:

When sending a POST request the controller performs this check:
if (!ModelState.IsValid)
mreturn ValidationHelper.ReturnValidationError(ModelState)

If the data sent contains an invalid value, IsValid=false and Postman display this response:
image

Steps to reproduce
Codegen the Odata controller template, make sure POST requests are enabled for the structure, import the Postman tests into Postman. Select any ALPHA field in the POST request and pass a numeric value instead, this should cause ModelState.IsValid=false.

Proposed solution:

It would be ideal if the response contained either the first field with a validation error OR better yet all invalid fields. It would further be ideal if the cause of the error is indicated per field (ie. "Alpha value expected").

Note: As of this writing, the only invalid condition I found was sending a numeric value in an ALPHA field. Other conditions tested below are NOT considered invalid:

  • Send alpha data in a numeric field (if the opposite is considered invalid, shouldn't this also be invalid?)
  • Send a value that is too large for the destination field. Ex. send "ZY" to an A1 field or 99 to a D1 field behaves as described in the assignment statements implicit formatting rules in the Synergy doc. (IMO, this is reasonable behavior and should not be considered invalid)
@KishB KishB added the enhancement New feature or request label Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant