Newer
Older
sanitizer / README.md

Sanitizer

Annotate member variables for sanitation

public class User {
    @ConcurrentSpace
    private String name;
}

Instantiate

Sanitizer sanitizer = new Sanitizer(object);

Sanitize

sanitizer.sanitize();

Accent

Strip accents from characters

@Accent

Data types supported

  • String

Concurrent Space

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

  • String

Lowercase

Lowercase all characters

@Lowercase

Data types supported

  • String

Remove

Removes all instances of given string

@Remove("-")

Required

  • toRemove - [String]

Data types supported

  • String

Trim

Remove leading and trailing spaces

@Trim

Data types supported

  • String

Trim to Null

Remove leading and trailing spaces and return null if empty

@TrimToNull

Data types supported

  • String

Uppercase

Uppercase all characters

@Uppercase

Data types supported

  • String

Custom

Sanitizes against a custom class

@CustomSanitizer(MyCleanser.class)

Required

  • value - Class that implements Cleanser

Note: Custom validation class must implement the Cleanser interface

TODO

Handle exception from CustomSanitizer