Apache Struts 2 Documentation > Home > Guides > Core Developers Guide > Validation > email validator
Added by tm_jee, last edited by Philip Luppens on Feb 10, 2007  (view change) show comment


EmailValidator checks that a given String field, if not empty, is a valid email address.

The regular expression used to validate that the string is an email address is:



  • fieldName - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required


<!-- Plain Validator Syntax -->
    <validator type="email">
        <param name="fieldName">myEmail</param>
        <message>Must provide a valid email</message>

<!-- Field Validator Syntax -->
<field name="myEmail">
   <field-validator type="email">
      <message>Must provide a valid email</message>