Package com.jk.core.validation.builtin
Enum Class FSValidators
- All Implemented Interfaces:
Validator
,Serializable
,Comparable<FSValidators>
,Constable
This enum provides a set of predefined validation rules for various types of
data.
These validation rules can be used to validate strings or other data types according to specific criteria.
- Version:
- 1.0
- Author:
- Dr. Jalal H. Kiswani
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionValidates that the provided string is a valid character set name.Validates that the provided string is a valid email address.Validates that the provided path represents an existing directory.Validates that the provided path represents an existing file.Validates that a file with the provided filename exists in the file system.Validates that a file with the provided filename does not exist in the file system.Validates that the provided string is a valid host name.Validates that the provided string is either a valid host name or a valid IP address.Validates that the provided string is a valid IP address.Validates that the provided string is a valid Java package name.Validates that the provided string does not start with a digit.Checks that the input string does not contain any whitespace characters.Validates that the provided input string is a valid Java identifier.Ensures that the input string is not empty.Ensures that the input number is non-negative (greater than or equal to zero).Validates that the input string can be used as a valid filename.Validates that the input string represents a valid integer number.Validates that the input string represents a valid number, including both integers and decimals.Validates that the provided string is a valid URL.Validates that the input string represents a valid hexadecimal number. -
Method Summary
Modifier and TypeMethodDescriptiondisallowChars
(char[] chars, boolean trim) This method creates a validator that disallows specified characters.encodableInCharset
(String charsetName) This method creates a validator that checks if a string can be encoded in a specified charset.This method creates a validator that checks if a given input string conforms to the specified format.forString
(boolean trim) This method creates a validator for strings based on the specified validation rule.maxLength
(int length) This method creates a validator that checks if the length of a given input string does not exceed a specified maximum length.This method creates a validator by merging multiple validators together.static <T> Validator<T>
This method creates a validator by merging multiple validators together.minLength
(int length) This method creates a validator that checks if a string has a minimum length.numberRange
(Number min, Number max) This method creates a validator that checks if a number falls within a specified range.This method creates a validator that checks if a string matches a regular expression pattern.splitString
(String regexp, Validator<String> other) This method creates a validator that splits a string using a regular expression and validates each resulting substring using the provided validator.trim()
This method creates a validator for strings that trims the input string before validation.trimString
(Validator<String>... others) This method creates a validator that trims the input string and then validates it using the provided validators.boolean
This method validates the given model and populates the provided `Problems` object with any validation issues.This method creates a validator for ensuring that the input string represents a valid number.static FSValidators
Returns the enum constant of this class with the specified name.static FSValidators[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
REQUIRE_NON_EMPTY_STRING
Ensures that the input string is not empty. It checks if the string has at least one character. -
REQUIRE_VALID_FILENAME
Validates that the input string can be used as a valid filename. It checks for characters that are not allowed in filenames. -
REQUIRE_VALID_INTEGER
Validates that the input string represents a valid integer number. -
REQUIRE_NON_NEGATIVE_NUMBER
Ensures that the input number is non-negative (greater than or equal to zero). -
REQUIRE_VALID_NUMBER
Validates that the input string represents a valid number, including both integers and decimals. -
REQUIRE_JAVA_IDENTIFIER
Validates that the provided input string is a valid Java identifier. -
VALID_HEXADECIMAL_NUMBER
Validates that the input string represents a valid hexadecimal number. -
NO_WHITESPACE
Checks that the input string does not contain any whitespace characters. -
FILE_MUST_EXIST
Validates that a file with the provided filename exists in the file system. -
FILE_MUST_BE_FILE
Validates that the provided path represents an existing file. -
FILE_MUST_BE_DIRECTORY
Validates that the provided path represents an existing directory. -
URL_MUST_BE_VALID
Validates that the provided string is a valid URL. -
IP_ADDRESS
Validates that the provided string is a valid IP address. -
HOST_NAME
Validates that the provided string is a valid host name. -
HOST_NAME_OR_IP_ADDRESS
Validates that the provided string is either a valid host name or a valid IP address. -
MAY_NOT_START_WITH_DIGIT
Validates that the provided string does not start with a digit. -
EMAIL_ADDRESS
Validates that the provided string is a valid email address. -
CHARACTER_SET_NAME
Validates that the provided string is a valid character set name. -
JAVA_PACKAGE_NAME
Validates that the provided string is a valid Java package name. -
FILE_MUST_NOT_EXIST
Validates that a file with the provided filename does not exist in the file system.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
disallowChars
This method creates a validator that disallows specified characters.- Parameters:
chars
- Specifies the characters to disallow.trim
- Specifies if the input should be trimmed before validation.- Returns:
- the validator disallowing the specified characters.
-
encodableInCharset
This method creates a validator that checks if a string can be encoded in a specified charset.- Parameters:
charsetName
- Specifies the name of the charset to validate against.- Returns:
- the validator for charset encoding.
-
forFormat
This method creates a validator that checks if a given input string conforms to the specified format.- Parameters:
fmt
- Specifies the Format object representing the desired format for validation.- Returns:
- the validator that validates strings based on the specified format.
-
maxLength
This method creates a validator that checks if the length of a given input string does not exceed a specified maximum length.- Parameters:
length
- Specifies the maximum allowed length for the input string.- Returns:
- the validator that ensures the input string's length does not exceed the specified maximum.
-
merge
This method creates a validator by merging multiple validators together.- Parameters:
trim
- Indicates whether to trims the input string before validation or not.validators
- Specifies the array of validators to merge.- Returns:
- the merged validator that applies all specified validators to the input string.
-
merge
This method creates a validator by merging multiple validators together.- Type Parameters:
T
- Specifies the type of input the validators accept.- Parameters:
validators
- Specifies the list of validators to merge.- Returns:
- the merged validator that applies all specified validators to the input.
-
minLength
This method creates a validator that checks if a string has a minimum length.- Parameters:
length
- Specifies the minimum length that the string must have.- Returns:
- the validator that ensures the input string has at least the specified minimum length.
-
numberRange
This method creates a validator that checks if a number falls within a specified range.- Parameters:
min
- Specifies the minimum value of the range (inclusive).max
- Specifies the maximum value of the range (inclusive).- Returns:
- the validator that ensures the input number is within the specified range.
-
regexp
This method creates a validator that checks if a string matches a regular expression pattern.- Parameters:
regexp
- Specifies the regular expression pattern to match against.message
- Specifies the error message to display if the validation fails.acceptPartialMatches
- Specifies whether partial matches are considered valid.- Returns:
- the validator that checks if the input string matches the given regular expression pattern.
-
splitString
This method creates a validator that splits a string using a regular expression and validates each resulting substring using the provided validator.- Parameters:
regexp
- Specifies the regular expression pattern used to split the input string.other
- Specifies the validator to apply to each substring resulting from the split.- Returns:
- the validator that splits the input string and validates each substring using the provided validator.
-
trimString
This method creates a validator that trims the input string and then validates it using the provided validators.- Parameters:
others
- Specifies the validators to apply to the trimmed input string.- Returns:
- the validator that trims the input string and then validates it using the provided validators.
-
validNumber
This method creates a validator for ensuring that the input string represents a valid number.- Returns:
- the validator that checks whether the input string represents a valid number.
-
forString
This method creates a validator for strings based on the specified validation rule.- Parameters:
trim
- Specifies whether the created validator will also trim the input string before validation.- Returns:
- the validator for strings based on the specified validation rule.
-
trim
This method creates a validator for strings that trims the input string before validation.- Returns:
- the validator for strings that trims the input string before validation.
-
validate
This method validates the given model and populates the provided `Problems` object with any validation issues.- Specified by:
validate
in interfaceValidator
- Parameters:
problems
- Specifies the `Problems` object to store validation problems.compName
- Specifies the name or identifier of the component being validated.model
- Specifies the model to be validated.- Returns:
- true, if validation succeeded without problems, false otherwise.
-