Grules


Wiki Groovydoc Introduction video
Grules is a rule engine for data preprocessing (validation and canonicalization). The rules are specified via internal Groovy DSL, which has a concise and simple syntax. For example:
// isEmail is a Groovy/Java method that takes an email value as its parameter
email isEmail ["Invalid email"]

// invalidLoginError and dupLoginError are String error messages
login isLogin [invalidLoginError] >> isUnique [dupLoginError]

// Gender is a Groovy/Java enumeration
gender toEnum(Gender)

// "10001" is a default value
zipcode["10001"] isValidZipcode

// agreeToTerms is a message from a resource bundle
termsCondition[""] !isEmpty [m.agreeToTerms]

// you can use closures as well
weight toPositiveBigDecimal [decimalError] >> {round(it / 1000)}

// Grules supports logical operators
endDate isAfterNow && isBefore(deadline) && {it.day != 1}

Download .zip Download .tar.gz View on GitHub