You are here: Reference > Rule types > Edit Validates > Edit Validate form - Completing the Java tab

Edit Validate form
Completing the Java tab

  1. About 
  2. New 
  3. Java 
  4. History 
  5. More... 

Enter the body of a Java boolean function here. The value your Java code is to validate is in an automatically declared variable named theValue.

Design the function to return true when the value is valid, and otherwise return false.

Note: Your validation code can check character limitations, format limitations, or value range limitations. However, do not implement cross-edits — comparisons of one input field against another — in edit validate rules that are to be used in client-side validation, as the other inputs may not be available at the time the edit validate rule executes.

See Edit Validate form Completing the Java tab for additional guidance on Java code that you can use here.

Field

Description

Java Source  
Java

Enter your Java source directly into the Java Source text box.

Include a Java return statement in the Java source code.

Note: Use the String.equals() Java method, not the == or != operators, to compare the value of a property to a literal string or to the value of another property.

You can use the normal syntax to call a function rule:

ruleset_library.FunctionName(arg1, arg2, arg3)

where the RuleSet and library name are in lowercase but the function name is in exact case. For example:

double d_result = pegarules_math.Sqrt("4")

Notes

To associate text from a message rule with the property, use the addMessage() PublicAPI method, as in following Java statement:

theProperty.addMessage("RuleMessageKey\tText1\tText2...");

where RuleMessageKey is a key to a Rule-Message rule, and the optional Text1, Text2 and so on are text values — separated by a backslash and literal t character — that supply values for the numbered parameters {1}, {2},... in the message rule text. (This method has no effect if the message identified by RuleMessageKey is already present.)