Validator
Validator is a simple library that help you to handle form validation.
It's a painful task that needs to be automated.
Fortunately my lib is here for you. It will save you a lot of time!
Tests
The tests are run by circle-ci :
Simple use case with spark
Import this in your code base: SparkForm.java
post("/test/", (r, q) -> {
Map<String, String> check = new Validator(new SparkForm(r))
.addRule("title -> max_length: 100 | min_length: 10")
.addRule("price -> range: 0, 99999")
.addRule("website -> url")
.addRule("email -> email")
.addRule("tags -> json_arr | diff: (:1)", new JSONArray().put("hey").put("this is a replacement").toString())
.check();
if (!check.isEmpty()) {
return "Somes errors, check is key/value where key=field and value=error message";
}
return "No error here!";
});