Ignore @NotNull on validation

251 views
Skip to first unread message

toniObject

unread,
Dec 11, 2015, 3:39:22 AM12/11/15
to play-framework
Hello,

Is it possible to ignore @NotNull annotations when validating an object. After the validation I get some ugly validation errors based on NotNull. 

Thanks,
Toni 

toniObject

unread,
Dec 11, 2015, 3:40:31 AM12/11/15
to play-framework
Sorry, I forgot to mention that I'm running play version 2.3 with JDK 1.8.

HHeinz

unread,
Dec 11, 2015, 7:31:47 AM12/11/15
to play-framework
Hello Toni, 

Maybe this stack overflow question can help you!?

It describes the concept of partial validation (with example) if you are using Java.

Another way might be to put the field on the form as hidden value (then it should not be null anymore) or try to "validate" with @Column(nullable=false).
If you save to a database this could work but will throw an exception if you try to save a null value at a later point.

I must admit that I haven't tested this so I could be totally wrong but the best solution is imho mentioned in the stack overflow link anyway. 
Have a nice week-end

Henning



Am Freitag, 11. Dezember 2015 09:39:22 UTC+1 schrieb toniObject:

Elton Marku

unread,
Dec 11, 2015, 7:44:57 AM12/11/15
to play-fr...@googlegroups.com
Hi Henning,

Thank you so much, now it’s clear how to do it.

Regards,
Toni

--
You received this message because you are subscribed to a topic in the Google Groups "play-framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/play-framework/pzHHWO6CGc8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to play-framewor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/f5530f94-79ca-4856-8881-e5ad1000e114%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages