Class PhoneE164Sanitizer
java.lang.Object
io.github.rabinarayanpatra.sanitizer.builtin.PhoneE164Sanitizer
- All Implemented Interfaces:
FieldSanitizer<String>
Sanitizer that normalizes a phone number to E.164 format by stripping
non-digit characters and prepending a
+.
This sanitizer assumes the input already includes the full international number with country code. It is useful for ensuring consistent phone number representation across systems.
String input = "(202) 555-0198";
String sanitized = new PhoneE164Sanitizer().sanitize(input); // "+2025550198"
- Since:
- 1.0.0
- See Also:
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
PhoneE164Sanitizer
public PhoneE164Sanitizer()Default constructor.
-
-
Method Details
-
sanitize
Converts the input to E.164 format by removing all non-digit characters and prefixing with+.- Specified by:
sanitizein interfaceFieldSanitizer<String>- Parameters:
in- the input phone number- Returns:
- the normalized E.164 phone number, or
nullif the result is empty or input isnull
-