Annotate member variables for sanitation
public class User {
@ConcurrentSpace
private String name;
}
Instantiate
Sanitizer sanitizer = new Sanitizer(object);
Sanitize
sanitizer.sanitize();
Strip accents from characters
@Accent
Data types supported
Replaces all concurrent spaces with single space
@ConcurrentSpace
Example:
User user = new User("John Doe");
new Sanitizer(user).sanitize();
System.out.println(user.getName());
Output
John Doe
Data types supported
Lowercase all characters
@Lowercase
Data types supported
Removes all instances of given string
@Remove("-")
Required
Data types supported
Remove leading and trailing spaces
@Trim
Data types supported
Remove leading and trailing spaces and return null if empty
@TrimToNull
Data types supported
Uppercase all characters
@Uppercase
Data types supported
Sanitizes against a custom class
@CustomSanitizer(MyCleanser.class)
Required
Note: Custom validation class must implement the Cleanser interface
Handle exception from CustomSanitizer