This project is a small extension, that allows to check data with some conditions for each datatype.
The check is performed lazily when method isValid is called. Since every method returns current object, methods can be called successively.
An example:
Validator v = new Validator(); // create validator object
StringSchema schema = v.string(); // specify string validation
schema.isValid(""); // true
schema.isValid(null); // true
schema.required(); // we require string to have any value
schema.isValid(null); // false
schema.isValid("what does the fox say"); // true
schema.minLength(5); // we require string to have length an least 5
schema.isValid("what"); // false
schema.contains("what"); // we require string to contain "what"
isValid("what does the fox say") // true
There are 3 datatypes now:
- Strings
- Not null check
- Minimal length check
- Substring containment check
- Integers
- Not null check
- Positivity check
- Number is in range check
- Maps
- Not null check
- Minimal size check
- Check conditions above for string and integer values inside Map
New datatypes and checks will be added soon!