Sanitizer

@aljunggren aljunggren authored on 15 Feb 2022
src Updated lombok and junit versions 4 years ago
.gitignore Initial commit 6 years ago
README.md Annotation cleanup 5 years ago
lombok.config Added lombok.config 5 years ago
pom.xml Updated lombok and junit versions 4 years ago
README.md

Sanitizer

Annotate member variables for sanitation

public class User {
    @ConcurrentSpace
    private String name;
}

Instantiate

Sanitizer sanitizer = new Sanitizer(object);

Sanitize

sanitizer.sanitize();

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

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