Class ValidatorSettings
java.lang.Object
com.codingchili.core.configuration.system.ValidatorSettings
Contains settings for validating strings with regexes, length and field names.
-
Constructor Summary
ConstructorsConstructorDescriptionValidatorSettings(String name)Creates a new settings object with no field validation enabled by default. -
Method Summary
Modifier and TypeMethodDescriptionaddRegex(RegexAction action, String expression)addRegex(RegexAction action, String expression, String substitution)booleangetKeys()intintgetName()getRegex()inthashCode()booleanisFieldValidated(String field)length(int min, int max)voidvoidsetMaxLength(int maxLength)voidsetMinLength(int minLength)setRegex(List<RegexComponent> regex)
-
Constructor Details
-
ValidatorSettings
Creates a new settings object with no field validation enabled by default.- Parameters:
name- the name of the ruleset.
-
-
Method Details
-
getName
- Returns:
- the name of the ruleset.
-
getRegex
- Returns:
- a list of regexes to apply for the matching fields.
-
setRegex
- Parameters:
regex- a list of regular expressions to apply on matching fields.- Returns:
- fluent.
-
getKeys
- Returns:
- a list of field names for which validation is to be enabled. if empty - all fields are validated.
-
setKeys
- Parameters:
keys- a list of fields that will be validated, if empty then all fields are validated.
-
getMinLength
public int getMinLength()- Returns:
- the minimum length of the input.
-
setMinLength
public void setMinLength(int minLength)- Parameters:
minLength- the minimum length of the input.
-
getMaxLength
public int getMaxLength()- Returns:
- the maximum length of the input.
-
setMaxLength
public void setMaxLength(int maxLength)- Parameters:
maxLength- the maximum length of the input.
-
addKey
- Parameters:
key- specifies that this key needs validation, when called validation for all fields not listed are disabled. The keys does not consider the object hierarchy, this is a plain field name.- Returns:
- fluent.
-
addKeys
- Parameters:
keys- a list of keys to add, seeaddKey(String).- Returns:
- fluent.
-
length
- Parameters:
min- the minimum length of the field being validated.max- the maximum length of the field being validated.- Returns:
- fluent.
-
addRegex
- Parameters:
action-addRegex(RegexAction, String, String)expression- the regular expression configuration used to match input.- Returns:
- fluent.
-
addRegex
- Parameters:
action- the action to take when the expression matches the input.expression- the regular expression configuration used to match input.substitution- used whenRegexAction.SUBSTITUTEis set.- Returns:
- fluent.
-
isFieldValidated
- Parameters:
field- the field to check if validation should be performed.- Returns:
- true if the field needs validation, if it's added to the checked keys or if the fieldset is empty.
-
hashCode
public int hashCode() -
equals
-