Validations Cheat Sheet
Validation Expressions Cheat Sheet
This readme describes how to create validations in Stadium 6.12+.
Overview
The release of Stadium 6.12 brings some changes to how Control validations work in Stadium. Instead of a simple selection from a limited set of predefined options, we can now use expressions to flexibly validate control values and properties as well as the values and properties of related controls.
Full feature set:
Custom validation definition using Javascript expressions
Custom error message definition
Programmatic error state setting
Programmatic error message definition
When upgrading a pre- 6.12 application in the 6.12 Stadium Designer, older validations will automatically be upgraded.
Stadium Version
6.12+
Required / Not Required
To mark a Control as required, check the "Required" checkbox and enter a validation message
IsValid
The "IsValid" property is a boolean flag that defines when Controls are in an error state. This property is "true" by default and is set to "false" when it fails an "IsValid Rule". It can also be set programmatically in scripts.
IsValid Rule
The "IsValid Rule" property accepts a Javascript expression. If the Control value passes the expression the IsValid property is true and the Control has passed the validation. If the Control value does not pass the expression the IsValid property is false, the Control is placed in an error state and the error message is displayed under the Control.
Copy-and-Paste Expressions
A wide range of validations can be performed with the help of regular expressions. However, regular expressions are not always easy to write. Below are regular expressions for all current Stadium validations.
To use these examples, adjust the Control name ("TextBox" in this example) and copy & paste any of these expressions into the "IsValid" rule in the properties panel
IsEmail
IsAmount
IsNumber
IsURL
With http / https
Text length is 8 or more
Password validation
Rules: 8 – 16 characters, at least one number, at least one special character
Characters only
Use AI to generate a RegEx
If you need a specific RegEx, but are not sure how to write it, I came across a function in the Google Gemini AI tool that will generate a RegEx from a text prompt.
Google AI Studio RegEx Text Prompt
Here is an example prompt for a complex RegEx:
The result:
Implementing this as a Stadium Validation:
Date Range (DatePicker)
Date between Jan 1, 2023 & today
Number Range
Number between 1 and 12
Combining criteria
When values from one or from more Controls are required to adhere to multiple criteria (x AND y), the criteria can be combined by adding a double ampersand (&&)
When values from one or from more Controls are required to adhere to any listed criteria (x OR y), the criteria can be combined by adding a double pipe (||)
Script-Based Validations
Validation errors can be triggered in scripts by setting "IsValid" flags and "Error Text" properties using SetValue actions.
If an "IsValid" flag is set to "false", the text provided in the "Error Text" property is shown under the field. The "IsValid" flag will remain "false" until it is set to "true" using another SetValue action.
Scripts execute once all controls pass the "IsValid Rules". Script executions do NOT stop when an "IsValid" flag is set to "false". Data processing may need to be done conditionally as shown.
Last updated