Grooper 21.00.0082 is available as of 12-12-2023! Check the  Downloads Discussion  for the release notes and to get the latest version.
Grooper 23.1.0016 is available as of 03-15-2024! Check the  Downloads Discussion  for the release notes and to get the latest version.
Grooper 23.00.0042 is available as of 03-22-2024! Check the Downloads Discussion for the release notes and to get the latest version.

Validation Script

Hi, I would like to enhance my data validation for fields. One way to do this would be to use Regular Expressions in the validation. One simple example would be to validate using a regular expression. This is just a sample the actual expression will more than likely have more complexity.



The Regex class is found in the .net library "System.Text.RegularExpression".
Src: https://docs.microsoft.com/en-us/dotnet/api/system.text.regularexpressions.regex?view=netframework-4.7.2

How do I include a reference to this library, so I can use it for validation?


Also it may make sense to encapsulate some of the more complex checks in a function that I can re-use in multiple fields.
Where do I write this function and how do I reference it in the individual fields validation scripts?

Example of a function that looks for how many 'unusual' characters are in a field value (simplified) and declares it invalid if there are more than three.

Public Function TestValidationUnusualCharacters(input as String)
  Return input.ToCharArray().Count(function(c) {"|","%","^"}.Contains(c)) <= 3
End Function



Comments

  • GrooperGuruGrooperGuru Posts: 481 admin
    You are getting into complexity that the expressions are not equipped to handle. But there is good news. You can add a Script to the Data Model itself. In this script you can fire any kind of validation logic you want. To use this interface you'll have to have visual studio and the Microsoft VSTA components installed on your machine. This will allow you to write and edit code from visual studio. When you debug from Visual Studio, it will launch a new instance of Design Studio that takes advantage of your code. You can navigate sample batches to see the results. When finished, you close visual studio. You'll be returned to Grooper where you can save changes and compile your code. Restart Design Studio, and you'll be all set.
    Matt Harrison
    Product Manager
    mharrison@bisok.com
Sign In or Register to comment.