[ANN] Grules - DSL for data preprocessing

[ANN] Grules - DSL for data preprocessing

This post was updated on .

I would like to announce a new project called Grules that I have worked on for two years. It is a Groovy DSL for data preprocessing, i.e. validation and canonicalization.

Validation of input parameters is usually defined using IF statements and exceptions. With a lot of parameters such code becomes less readable and frequently is split between different methods and classes. Furthermore, when a new parameter appears it is easy to forget about its validation, escaping of special symbols, string trimming, etc. To solve these and other problems with input validation, I wrote a Groovy library that allows to define data preprocessing rules via DSL. For example, the following script handles six input parameters: email, login, gender, terms and conditions checkbox, weight, and end date:

// isEmail is a Groovy/Java method that takes an email value as its parameter
email isEmail ["Invalid email"]

As the result of this script one will get a map of objects with input values divided in 5 groups:
- valid
- invalid
- missings
- for which a preprocessing rule was not found
- with missing or invalid values dependencies

To include support of the DSL into your project, just add grules.jar to classpath (for example via Maven), and add Groovy scripts that contain validation rules for your data (file names of the scripts must end with Grules).

Re: Grules - DSL for data preprocessing

I would like to announce a new project called Grules that I have worked on
for two years. It is a Groovy DSL for data preprocessing, i.e. validation
and canonicalization.

Validation of input parameters is usually defined using IF statements and
exceptions. With a lot of parameters such code becomes less readable and
frequently is split between different methods and classes. Furthermore, when
a new parameter appears it is easy to forget about its validation, escaping
of special symbols, string trimming, etc. To solve these and other problems
with input validation, I wrote a Groovy library that allows to define data
preprocessing rules via DSL. For example, the following script handles six
input parameters: email, login, gender, terms and conditions checkbox,
weight, and end date:

// isEmail is a Groovy/Java method that takes an email value as its
parameter
email isEmail ["Invalid email"]

As the result of this script one will get a map of objects with input values
divided in 5 groups:
- valid
- invalid
- missings
- for which a preprocessing rule was not found
- with missing or invalid values dependencies