Class TruncateSanitizer
java.lang.Object
io.github.rabinarayanpatra.sanitizer.core.ConfigurableFieldSanitizer<String>
io.github.rabinarayanpatra.sanitizer.builtin.TruncateSanitizer
- All Implemented Interfaces:
FieldSanitizer<String>
Configurable sanitizer that truncates strings to a maximum length.
Accepts the following parameters via @Sanitize(params = "..."):
maxLength— the maximum allowed length (default: 255)suffix— appended when truncation occurs (default: empty). The suffix length is included in the maxLength limit.
@Sanitize(using = TruncateSanitizer.class, params = "maxLength=100,suffix=...") private String description;
- Since:
- 1.1.0
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class io.github.rabinarayanpatra.sanitizer.core.ConfigurableFieldSanitizer
configure, getIntParam, getParam, getParams, parseParams
-
Constructor Details
-
TruncateSanitizer
public TruncateSanitizer()Default constructor.
-
-
Method Details
-
sanitize
Truncates the input string to the configured maximum length.- Parameters:
input- the string to sanitize- Returns:
- the truncated string, or
nullif input isnull
-