Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Validating Field Content

...

<field type="rule" variable="EMAILaddress">
  <spec
      txt="Your Email address:" layout="O:12:U @ O:8:40 .
      A:4:4"
      set="0: 1:domain 2:com" resultFormat="displayFormat"
  />
  <validator
  class="com.izforge.izpack.panels.userinput.utilvalidator.RegularExpressionValidator"
       txt="Invalid email address!">
    <param
        name="pattern"
        value="[a-zA-Z0-9._-]{3,}@[a-zA-Z0-9._-]+([.][a-zA-Z0
        -9_-]+)*[.][a-zA-Z0-9._-]{2,4}"
    />
  </validator>
</field>

...

You can implement your own custom Validator implementation simply by creating a new class which implements the com.izforge.izpack.panels.userinput.validator.Validator interface. This interface specifies a single method: validate(ProcessingClient) , which returns a boolean value. You can retrieve the value entered by the user by casting the input ProcessingClient for example in the RuleInputField and call the RuleInputField.getText() method. You can also retrieve any parameters to your custom Validator by calling theRuleInputField.getValidatorParams() which returns a java.util.Map object containing parameter names mapped to parameter values. For an example, take a look at com.izforge.izpack.util.RegularExpressionValidator.