Static
Readonly
errorProtected
configThe business rules behind this validator.
Protected
servicesProtected
valueProtected
validationProtected
loggerProvides an API for logging, sending entries to the loggerService.
Provides the error code associated with this instance. It uses ValidatorConfig.errorCode when assigned and ConditionType when not assigned.
Condition used to validate the data. Run by validate(), but only if the Validator is enabled (severity<>Off and Enabler == Match) The actual Condition instance is created by the caller and supplied in the ValidatorConfig. WhenCondition is a special case. When it is the condition returned, its child Condition is used here as the WhenCondition is more of a container to supply both condition and Enabler with conditions.
Gets the conditionType associated with the condition
Protected
enablerCondition used to enable or disable this validator based on rules. severity = Off takes precedence. WhenCondition is a special case. When it is the condition returned, its child Condition is used here as the WhenCondition is more of a container to supply both condition and Enabler with conditions.
Determined from the Config.enabled. Does not use the Enabler.
Protected
severityDetermined from Config.severity.
Protected
getResolves the errorMessage as a template - before it has its tokens processed. It uses several sources to get the template. The first to have text is used.
Error message from errorMessage property with localization applied if ErrorMessagel10n is setup.
Protected
getResolves the summaryMessage as a template - before it has its tokens processed. Falls back to use GetErrorMessageTemplate if Config doesn't supply a value.
Error message from summaryMessage property with localization applied if SummaryMessagel10n is setup.
Perform validation activity and provide the results including whether there is an error (ConditionEvaluateResult), fully formatted error messages, severity, and Condition type.
Provides guidance on which validators to include.
Identifies the ConditionEvaluateResult. If there were any NoMatch cases, they are in the IssuesFound array.
Protected
supportsProtected
updatevalidate() found NoMatch. Update the IssueFound to show the current ConditionEvaluateResult and error messages.
this is a COPY of the IssueFound. Do not modify the actual instance as it is immutable.
When ValueHost.setBusinessLogicError is called, it provides each entry to the existing list of Validators through this. This function determines if the businessLogicError is actually for the same error code as itself, and returns a ValidatorValidateResult, just like calling validate() itself. The idea is to use the UI's representation of the validator, including its error messages with its own tokens, instead of those supplied by the business logic.
if null, it did not handle the BusinessLogicError. If a ValidatorValidateResult, it should be used in the ValueHost's state of validation.
Protected
nameInstanceState is stored in ValueHost's InstanceState using its saveIntoInstanceStare/getFromInstanceState. Each entry needs to be associated with the errorCode of this Validator and have its own identifier for the value. This function creates a name to use with saveToStore and getFromStore.
Protected
saveSaves an entry into the ValueHostInstanceState.
used together with the errorCode to form a key in the instanceState.
value to store. Use undefined to remove existing value.
Protected
getReturns an entry from the ValueHostInstanceState.
Often used to store values that override an entry in the ValidatorConfig. In that case, typical implementation is: let value = this.getFromInstanceState('identifier') ?? this.config.identifier;
used together with the errorCode to form a key in the instanceState.
The value or undefined if the key is not stored in state.
Use to change the enabled flag. It overrides the value from ValidatorConfig.enabled. Use case: the list of validators on ValidatorsValueHostBase might change while the form is active. Add all possible cases to ValidatorsValueHostBase and change their enabled flag here when needed. Also remember that you can use the enabler property on ValidatorConfig to automatically determine if the validator should run or not. Enabler may not be ideal in some cases though.
A service to provide all ValueHostNames that have been assigned to this Condition's Config.
Returns an array of 0 or more tokens supported by this MessageTokenSource.
Each returned has the token supported (omitting {} so {Label} is "Label")
and the value in its native data type (such as Date, number, or string).
Supports these tokens:
{Label} - the Config.label property verbatim
{Value} - the native value in instanceState.Value. If null/undefined, the value in instanceState.LastRawValue.
Plus any from the Condition in use.
{DataType} - the name of the data type. Uses values registered with TextLocalizerService and LookupKey enum's strings as a fallback.
Generated using TypeDoc v0.25.12
An IValidator implementation that represents a single validator for the value of an ValidatorsValueHostBase. It is stateless. Basically you want to call validate() to get all of the results of a validation, including ConditionEvaluateResult, error messages, severity, and more. That data ends up in the ValidationManager as part of its state, allowing the system consumer to know how to deal with the data of the ValueHost (save or not) and the UI to display the state.
Each instance depends on a few things, all passed into the constructor and treated as immutable.