-
Notifications
You must be signed in to change notification settings - Fork 38.1k
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
Consider mapping empty form values to [null] for Object properties [SPR-7544] #12201
Comments
Keith Donald commented I was able to plug in a empty String -> [null] mapping behavior by using a custom Converter<String, String>:
|
Rossen Stoyanchev commented This relates to #10090 to the extent that #10090 expects the target field to be set to "" (rather than null) given an empty string request parameter. |
Keith Donald commented There is also an inconsistency between how String fields are bound depending on if a formatter is registered or not, as pointed out by #12969 and #12038. |
Rossen Stoyanchev commented A duplicate of #12038. |
Keith Donald opened SPR-7544 and commented
Currently empty form fields are mapped to "" (empty string). This has several issues:
@NotNull
JSR-303 constraint or a "not null" relational DB constraint fails in this case. You're left with defining a min@Size
constraint or relying on a implementation-specific@NotEmpty
. In addition, there is no DB min constraint you can define at the Db level. Simply mapping "" to null would solve these problems and we could just rely on@NotNull
/not null.Affects: 3.0.4
Issue Links:
Formatter
subsystem'sParserConverter
skipsparse()
invocation if input string is empty [SPR-8321] #12969 Formatter subsystem's ParserConverter skips Parser invocation if input string is emptyThe text was updated successfully, but these errors were encountered: