Class ValuePatternBehavior
java.lang.Object
com.kingsrook.qqq.backend.core.model.metadata.fields.ValuePatternBehavior
- All Implemented Interfaces:
FieldBehavior<ValuePatternBehavior>,Serializable
Field behavior: a string value must match a regular expression (the whole
value, as Matcher.matches), or the record is refused on insert and update.
Empty values are left to isRequired. The pattern and its message are
published to frontends in the field's validation rules (UI API 1.6.0), so a
client can check a value before saving; the server stays the authority.
Write patterns that mean the same in Java and in ECMAScript (no possessive
quantifiers, lookbehind or inline flags), since clients test them in their
own regex engines.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructorValuePatternBehavior(String pattern, String message) Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoidapply(ValueBehaviorApplier.Action action, List<QRecord> recordList, QInstance instance, QTableMetaData table, QFieldMetaData field) Add an error to each record whose (non-empty) value does not match.No pattern by default.Getter for messagegetMessageFor(QFieldMetaData field) The message for a value that does not match.Getter for patternvoidsetMessage(String message) Setter for messagevoidsetPattern(String pattern) Setter for patternvalidateBehaviorConfiguration(QTableMetaData tableMetaData, QFieldMetaData fieldMetaData) allow this behavior to be validated during QInstance validation.withMessage(String message) Fluent setter for messagewithPattern(String pattern) Fluent setter for patternMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.kingsrook.qqq.backend.core.model.metadata.fields.FieldBehavior
allowMultipleBehaviorsOfThisType
-
Constructor Details
-
ValuePatternBehavior
public ValuePatternBehavior()Constructor -
ValuePatternBehavior
-
-
Method Details
-
getDefault
No pattern by default.- Specified by:
getDefaultin interfaceFieldBehavior<ValuePatternBehavior>
-
apply
public void apply(ValueBehaviorApplier.Action action, List<QRecord> recordList, QInstance instance, QTableMetaData table, QFieldMetaData field) Add an error to each record whose (non-empty) value does not match.- Specified by:
applyin interfaceFieldBehavior<ValuePatternBehavior>
-
getMessageFor
The message for a value that does not match. -
validateBehaviorConfiguration
public List<String> validateBehaviorConfiguration(QTableMetaData tableMetaData, QFieldMetaData fieldMetaData) Description copied from interface:FieldBehaviorallow this behavior to be validated during QInstance validation. return a list of validation errors, if there are any.- Specified by:
validateBehaviorConfigurationin interfaceFieldBehavior<ValuePatternBehavior>
-
getPattern
Getter for pattern -
setPattern
Setter for pattern -
withPattern
Fluent setter for pattern -
getMessage
Getter for message -
setMessage
Setter for message -
withMessage
Fluent setter for message
-