SudokuFX
Loading...
Searching...
No Matches
fr.softsf.sudokufx.common.enums.MyRegex Enum Reference

Utility class for managing and validating text against precompiled regular expressions. More...

+ Collaboration diagram for fr.softsf.sudokufx.common.enums.MyRegex:

Public Member Functions

Pattern getAlphanumericPattern ()
 
Pattern getSecretPattern ()
 
Pattern getVersionPattern ()
 
boolean isValidatedByRegex (final String text, final Pattern pattern)
 Validates the given text against the specified regex pattern.
 

Public Attributes

 INSTANCE
 

Private Member Functions

boolean isValidPassword (final String password)
 Validates a password string against strict security rules:
 

Static Private Attributes

static final Pattern ALPHANUMERIC_PATTERN = Pattern.compile("^[a-zA-Z0-9\\s.]+$")
 Precompiled regex pattern for validating alphanumeric strings.
 
static final Logger LOG = LoggerFactory.getLogger(MyRegex.class)
 
static final Pattern SECRET_PATTERN
 Precompiled regex pattern for validating passwords.
 
static final String SPECIAL_CHARACTERS = "@#$%^&()!"
 Allowed special characters for password validation.
 
static final Pattern VERSION_PATTERN
 Precompiled regex pattern for semantic versioning (e.g., X.Y.Z format).
 

Detailed Description

Utility class for managing and validating text against precompiled regular expressions.

This class includes methods for password validation, semantic versioning, alphanumeric string validation, and flexible contextual validations with error handling.

The class is implemented as a Singleton using an enum to ensure a single shared instance. It uses the SLF4J logging framework for error reporting.

Member Function Documentation

◆ getAlphanumericPattern()

Pattern fr.softsf.sudokufx.common.enums.MyRegex.getAlphanumericPattern ( )

◆ getSecretPattern()

Pattern fr.softsf.sudokufx.common.enums.MyRegex.getSecretPattern ( )

◆ getVersionPattern()

Pattern fr.softsf.sudokufx.common.enums.MyRegex.getVersionPattern ( )

◆ isValidatedByRegex()

boolean fr.softsf.sudokufx.common.enums.MyRegex.isValidatedByRegex ( final String text,
final Pattern pattern )

Validates the given text against the specified regex pattern.

If pattern equals the internal secret pattern, a stricter password validation is performed via isValidPassword(String).

Parameters
textthe text to validate; must not be null or blank
patternthe regex pattern to validate against; must not be null
Returns
true if the text matches the pattern or meets password criteria;
false
otherwise
Exceptions
IllegalArgumentExceptionif text is blank or pattern is null
+ Here is the call graph for this function:

◆ isValidPassword()

boolean fr.softsf.sudokufx.common.enums.MyRegex.isValidPassword ( final String password)
private

Validates a password string against strict security rules:

  • Must be exactly 24 characters long.
  • Contains only letters (uppercase and lowercase), digits, and special characters @#$%^&()!.
  • Includes at least 2 lowercase letters.
  • Includes at least 2 uppercase letters.
  • Includes at least 2 digits.
  • Includes at least 2 special characters from @#$%^&()!.
Parameters
passwordthe password to validate; must not be null or blank
Returns
true if the password meets all criteria, false otherwise
Exceptions
IllegalArgumentExceptionif password is null or blank

Member Data Documentation

◆ ALPHANUMERIC_PATTERN

final Pattern fr.softsf.sudokufx.common.enums.MyRegex.ALPHANUMERIC_PATTERN = Pattern.compile("^[a-zA-Z0-9\\s.]+$")
staticprivate

Precompiled regex pattern for validating alphanumeric strings.

Requirements: - Only letters, digits, spaces, and dots are allowed.

◆ INSTANCE

fr.softsf.sudokufx.common.enums.MyRegex.INSTANCE

◆ LOG

final Logger fr.softsf.sudokufx.common.enums.MyRegex.LOG = LoggerFactory.getLogger(MyRegex.class)
staticprivate

◆ SECRET_PATTERN

final Pattern fr.softsf.sudokufx.common.enums.MyRegex.SECRET_PATTERN
staticprivate
Initial value:
=
Pattern.compile("^[a-zA-Z0-9" + SPECIAL_CHARACTERS + "]{24}$")
static final String SPECIAL_CHARACTERS
Allowed special characters for password validation.
Definition MyRegex.java:30

Precompiled regex pattern for validating passwords.

Requirements: - Only letters (lowercase/uppercase), digits, and special characters #$%^&()! are allowed. - Exactly 24 characters in total.

◆ SPECIAL_CHARACTERS

final String fr.softsf.sudokufx.common.enums.MyRegex.SPECIAL_CHARACTERS = "@#$%^&()!"
staticprivate

Allowed special characters for password validation.

◆ VERSION_PATTERN

final Pattern fr.softsf.sudokufx.common.enums.MyRegex.VERSION_PATTERN
staticprivate
Initial value:
=
Pattern.compile("^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$")

Precompiled regex pattern for semantic versioning (e.g., X.Y.Z format).

Requirements: - Major, minor, and patch versions must be non-negative integers. - Each version component must be separated by a '.' character.


The documentation for this enum was generated from the following file: