Sanitizer

@Alex Ljunggren Alex Ljunggren authored on 12 Oct 2024
src Printing stacktrace 2 years ago
.gitignore Initial commit 6 years ago
Jenkinsfile New file 2 years ago
README.md Added Accent removal 4 years ago
lombok.config Added lombok.config 5 years ago
pom.xml Added build, distributionManagement, and scm 2 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();

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

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