*
The moose likes Struts and the fly likes Struts 2 required validator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 2 required validator" Watch "Struts 2 required validator" New topic
Author

Struts 2 required validator

Johnnie Smith
Greenhorn

Joined: May 02, 2012
Posts: 22
Hello,

I have read in the struts documentation about 2 validators required and requiredstring.

The required validator checks whether a field value is null.

The requiredstring validator checks whether a field value is null and also whether the field value is empty.

So the required validator will not find any error if a blank value is passed as the field value but requiredstring validator will not allow blank value to be submitted.

I have the following doubt: If the required validator is anyway going to allow blank values to be submitted what is the use of this validator? Suppose I have a field named userName where the required validation is carried out.

<field name="userName">
<field-validator type="required">
<param name="trim">true</param>
<message>Username must not be null</message>
</field-validator>
</field>


Under what circumstances will I get an error message?

Regards,
John

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Struts 2 required validator
 
Similar Threads
struts 2 - client side basic validation
Pop up error while using validation in struts2.0
error in validation
struts2 xml validator error message placement?
not validating