Skip to content

Add support for ignoring specific characters during masking in FixedLengthMasker#11

Merged
ehayik merged 2 commits intomasterfrom
feat/fixed-length-chars-ignore
Jun 21, 2025
Merged

Add support for ignoring specific characters during masking in FixedLengthMasker#11
ehayik merged 2 commits intomasterfrom
feat/fixed-length-chars-ignore

Conversation

@ehayik
Copy link
Owner

@ehayik ehayik commented Jun 10, 2025

Why

Add support to configure fixed-length masker to ignore specified characters during the masking process:

var masker = Masker.fixedLength()
    .ignore('-')
    .build();

var ssn = "123-45-6789";
var maskedSsn = masker.apply(ssn);
// Result: "***-**-****"

How

  • Updated FixedLengthMasker class to support characters ignoring
    • Added a new field charToIgnore and its corresponding constructor parameter.
    • Implemented new methods to handle masking while ignoring specified characters.
    • Updated logic in the existing methods to account for the charToIgnore feature.
    • Introduced a new method ignore(char) in Builder for specifying a character to ignore during masking.
  • Added tests to ensure the new feature works with different configurations.
  • Verified masking behavior when ignoring specified characters with prefix/suffix preservation.

…FixedLengthMasker

- Introduced the ability to preserve specified characters during fixed-length masking using the `ignore` method in the builder.
- Added logic in FixedLengthMasker to handle ignored characters, including when preserving prefixes and suffixes.
- Updated tests in FixedLengthMaskerTests to validate the new behavior.
@ehayik ehayik self-assigned this Jun 10, 2025
@ehayik ehayik added the enhancement New feature or request label Jun 10, 2025
@ehayik ehayik linked an issue Jun 10, 2025 that may be closed by this pull request
@ehayik ehayik added this to the v1.1.0 milestone Jun 10, 2025
…structor

- Replaced explicit constructor with Lombok's `@RequiredArgsConstructor` annotation to streamline initialization of final fields.
- Removed the now-redundant manual constructor implementation.
@sonarqubecloud
Copy link

@ehayik ehayik merged commit 5980b5f into master Jun 21, 2025
2 checks passed
@ehayik ehayik deleted the feat/fixed-length-chars-ignore branch June 21, 2025 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support to ignore specified characters in fixed-length masker

1 participant