How to create validator for editable grid
Good day,
I have an editable grid which I use to enter prices (e.g. 1000.99, 999.01). I would like to have a validator to check if the entered data is a number or not.
I tried creating a validator with type double numeric, float numeric, long numeric or short numeric but it didn't work.
Please help on how to do validation for the cells in the activity grid.
Thanks in advance.
Hi alfred.ayson,
Hello alfred.ayson,
On a 6.x version of the Bonita BPM Studio, I suggest you to use a Groovy Expression for your validation.
The existing numeric validator are useful for simple widget, but the editable grid return multiple values.
In the General> Validators>Add... , use the follow properties of you validator :
- Validator Type : select the 'Groovy expression'
- Error message : don't forget to fill this mandatory field.
- Parameter : edit a Script (Groovy Script) and here is an example of code to validate that all the entered data are numbers
for( Object s : (List<Object>) raw ){<br />
if(!((String)s).matches("^-?[0-9]+(\\.[0-9]+)?\$")){<br />
return false;<br />
}<br />
}<br />
}<br />
return true;
This code is a quick example, modify it for your own need.
Comments
Hi alfred.ayson,
To investigate on your trouble, can you precise the version of the Studio you are using ? 5.x or 6.x ?
I used the General > Validators > Add... options (validator type) provided in bonita community 6.2.1 when the editable grid widget is selected