OutSystems Platform enables you to validate the input of the end-user. Input validations can be automatic, or custom.
The OutSystems Platform offers automatic input validation of the value typed by the end-user, in Input widgets and Input Password widgets.
The inputs are valid when the following conditions for the widget properties are met:
Variable: The value typed by the end-user is compliant with the data type of the variable bound to the input widget;
Mandatory: The end-user must type a value for the input widget when 'Mandatory' is set to Yes.
As an example, if the input is bound to a variable with Date data type, the user must insert a date, or the input is invalid.
Note that the ‘Type’ property of the input doesn't affect the input validation, but modern browsers might display the input differently or automatically validate its content. As an example, if an input of type text is bound to a variable of type integer, the OutSystems Platform validates if the use has submitted a valid integer.
When the user presses a Button or Link to submit inputs, three different kinds of automatic validations can occur:
Client & Server: Validation of the inputs is performed on the client side. If the validation fails, then these values are not submitted to the server, the request is cancelled and the corresponding validation message is displayed. If the typed values are valid, then the request proceeds;
Server: The inputs are submitted to the server and their validation is performed at the server side. The runtime properties of the input widgets are updated and the screen action is executed even if an invalid input exists;
(none): Validation of the inputs are not performed. The 'Valid' runtime property of the input widgets submitted by the Button or Link is reset to True;
To specify the validation behavior, change the 'Validation' property of Buttons or Links.
Validation does not apply to links or buttons with the 'Method' property set to Navigate.
During the validation process, inputs are evaluated to check if value typed by the end-user complies with the data type of the variable to which the widget is bound. Runtime property of the widgets is affected:
If the end-user typed a value that complies with the variable data type, the 'Valid' runtime property of the widget is set to True;
If the end-user typed a value that does not comply with the variable data type, the 'Valid' runtime pro runtime property of the widget is set to False.
The 'ValidationMessage' runtime property is used during the validation of the typed values to hold the message to be displayed to the end-user:
If 'Valid' is True, 'ValidationMessage' is not displayed;
If 'Valid' is False, 'ValidationMessage' contains a message notifying the end-user that the validation failed. This message is defined in the default validation messages, but can also be assigned in the Screen Action logic.
OutSystems Platform provides the capability to create custom input validation of the value typed by the end-user. To create a custom validation you must give a name to the input element in its properties, and in a Screen Action access the runtime properties of the element. You can apply custom validations to the widgets:
As an example, you can give a name to an Input Password widget, and then in a Screen Action validate its content and if it is not valid set the runtime property 'Valid' to False and in the runtime property 'ValidationMessage' define the message to be displayed to the end-user.
When a Button or Link is pressed, all inputs belonging to the same Edit Record than the button or link (defined in the 'Validation Parent' property) are validated: widgets belonging to another Edit Record or which do not specify their parent Edit Record property, are not automatically validated.
In the validation process, if any input belonging to the Edit Record is invalid, the 'Valid' runtime property of that Edit Record is automatically set to False.