Initializing help system before first use

# Validating User Input

Even without any VDL modifications, as a user types into or selects a new value from a form field it is automatically validated.

By default, type validation is applied according to the data type of the base entity. When a field becomes invalid, it is highlighted until it becomes valid again.

You can manually enter the `<vdl-validate>` element to apply extra validation to fields—you must provide it with a pass attribute that is either a function or a Boolean expression which is evaluated every time a value is edited. For the example project, a boolean validator will ensure that the input field (i.e. the estimated ROI per share type expressed as a percentage) is greater than or equal to zero.

To add a `<vdl-validate>` element within the input field, so that the relevant part of your model now looks like the following, switch to the code editor using the link in the top right of the artboard. Locate the form in the code:

    <vdl-form>
        <vdl-field label="Max investment per share" parameter="MaxPerShare" size="4"></vdl-field>
        <vdl-field label="Max investment in high risk shares" parameter="MaxHighRisk" size="4"></vdl-field>
    </vdl-form>

Insert the snippet shown before the closing field tag so the form looks like this:

    <vdl-form>
    	<vdl-field label="Max investment per share" parameter="MaxPerShare" size="4">
    		<vdl-validate pass="=value >= 0">Investment must be zero or greater.</vdl-validate>
    	</vdl-field>
    	<vdl-field label="Max investment in high risk shares" parameter="MaxHighRisk" size="4">
    		<vdl-validate pass="=value <= 200">Max Investment per share is limited to 200</vdl-validate>
    	</vdl-field>
    </vdl-form>

The boolean expression `=value >= 0` is evaluated on the field's validation events which prevents a negative value being used. You can also provide text content for the `<vdl-validate>` element that forms part of a pop-up error dialogue when an invalid value is entered.

If you republish the app and enter an invalid value:
Figure : 1. Validating User Input
This is accompanied by a Validation Error dialog that contains the text provided as content for the element:
Figure : 2. Validation Error Dialog
There are several other validation options available, depending on your needs and their level of complexity. All are described in the main Xpress Insight documentation.
Parent Topic Using Expressions

© 2001-2026 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.