requiredstring validator Menu Toggle navigation Home Welcome Download Releases Announcements License Thanks! Sponsorship Privacy Policy Support User Mailing List Issue Tracker Reporting Security Issues Commercial Support End-of-Life Versions Version Notes Security Bulletins IntelliJ IDEA plugin Maven Project Info Struts Core Dependencies Plugin Dependencies Documentation Birds Eye Key Technologies Kickstart FAQ Wiki Getting Started Security Guide Core Developers Guide Tag Developers Guide Maven Archetypes Plugins Struts Core API Tag reference FAQs Plugin registry Contributing You at Struts How to Help FAQ Development Lists Submitting patches Source Code and Builds Coding standards Contributors Guide Release Guidelines PMC Charter Volunteers Source Repository Updating the website Edit on GitHub requiredstring validator Description Parameters Examples Description RequiredStringValidator checks that a String field is non-null and has a length > 0. (i.e. it isn’t “”). The trim parameter determines whether it will String#trim() the String before performing the length check. If unspecified, the String will be trimmed. Parameters fieldName - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required. trim - (Optional) Boolean, default true. Trims the field name value before validating. trimExpression - (Optional) String. Specifies the trim param as an OGNL expression. Examples <validators> <!-- Plain-Validator Syntax --> <validator type="requiredstring"> <param name="fieldName">username</param> <param name="trim">true</param> <message>username is required</message> </validator> <!-- Field-Validator Syntax --> <field name="username"> <field-validator type="requiredstring"> <param name="trim">true</param> <message>username is required</message> </field-validator> </field> <!-- Field-Validator Syntax with expression --> <field name="username"> <field-validator type="requiredstring"> <param name="trimExpression">${trimValue}</param> <!-- will be evaluated as: boolean getTrimValue() --> <message>username is required</message> </field-validator> </field> </validators> Copyright © 2000-2025 The Apache Software Foundation. Apache Struts, Struts, Apache, the Apache feather logo, and the Apache Struts project logos are trademarks of The Apache Software Foundation. All Rights Reserved. Logo and website design donated by SoftwareMill. Follow @x