Package com.ntu.fdae.group1.bto.utils
Class ValidationUtil
java.lang.Object
com.ntu.fdae.group1.bto.utils.ValidationUtil
Utility class providing validation methods for common data types and formats
in the BTO Management System.
This class contains static methods for validating various inputs against specific format requirements, such as NRIC validation. It provides a centralized location for all validation logic to ensure consistency throughout the application.
All methods in this class are designed to be null-safe and follow consistent validation patterns.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Defines the set of special characters allowed in passwords. -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
isValidNric
(String nric) Validates if a string conforms to the Singapore NRIC format.static String
validatePasswordStrength
(String password) Validates a password against the defined strength criteria.
-
Field Details
-
ALLOWED_SPECIAL_CHARS
Defines the set of special characters allowed in passwords.- See Also:
-
-
Method Details
-
isValidNric
Validates if a string conforms to the Singapore NRIC format. This method checks if the provided string:- Is not null
- Matches the NRIC format pattern: starting with S, T, F, or G, followed by exactly 7 digits, and ending with a capital letter
The validation only checks the format and not whether the NRIC is actually valid according to the checksum algorithm.
- Parameters:
nric
- The NRIC string to validate- Returns:
- true if the string is in valid NRIC format, false otherwise (including for null input)
-
validatePasswordStrength
Validates a password against the defined strength criteria. Criteria: - Between MIN_LENGTH and MAX_LENGTH characters (inclusive) - At least 1 uppercase letter - At least 1 lowercase letter - At least 1 digit - At least 1 special symbol (from ALLOWED_SPECIAL_CHARS) - No whitespace characters- Parameters:
password
- The password string to validate.- Returns:
- A String containing an error message if validation fails, or null if the password is valid.
-