Sets up a function to lazy load the configuration when any of the other functions are called.
Services accessor. Note: Not passed into the constructor because this object should be created before ValidationServices itself. So it gets assigned when the associated service property on ValidationService is assigned the service instance.
Provides access to services.
Protected
loggerProvides an API for logging, sending entries to the loggerService.
Protected
indexUtility for register() to identify an already registered item that can be replaced by the supplied item.
an index into the getAll collection of a match or -1 if no match.
Return the value converted from the original value to the desired resultLookupKey. It may be a reworking of the original value, such as a Date object converted to a number of seconds, or a number rounded to an integer. Return null if the value represents null. Return undefined if the value was unconvertable. See also convertUntilResult() for a more complex conversion.
The value to be converted. Check its type and possibly its content.
The value can represent several other values, such as a Date represents date, time, etc. Use this when you need to distinguish between them. If null or '', evaluate the value itself, such as checking its class (using 'instanceof') or for properties of an interface that you are using. This is often the dataType property of the ValueHost.
An object identifying the converter used and the converted value. Its value parameter is undefined when the value was not converted. Its converterUsed parameter is undefined when no DataTypeConverter could be found to try the conversion. Note that DataTypeConverter.convert() can return undefined, allowing for value=undefined and converterUsed=assigned.
Applies a converter specific to the value based on the desired result lookup key. If the result is an object (like Date or custom), it repeats with the new value, hopefully resulting in a primitive value for use by the DefaultComparer. Date -> number using UTCDateConverter RelativeDate class with getDate(): Date property -> Date -> number using RelativeDateConverter and UTCDateConverter.
The value to be converted. Check its type and possibly its content.
The value can represent several other values, such as a Date represents date, time, etc. Use this when you need to distinguish between them. If null or '', evaluate the value itself, such as checking its class (using 'instanceof') or for properties of an interface that you are using. This is often the dataType property of the ValueHost.
An object identifying the converter used and the converted value. Its value parameter is undefined when the value was not converted. Its converterUsed parameter is undefined when no DataTypeConverter could be found to try the conversion. Note that DataTypeConverter.convert() can return undefined, allowing for value=undefined and converterUsed=assigned.
Protected
convertThis function attempts to convert a given value to a target lookup key specified by resultLookupKey, potentially through multiple intermediate conversion steps. It operates recursively, attempting to find a chain of converters that collectively can transform the input value into the desired output format.
Each converter is capable of converting values to one or more output lookup keys, identified by DataTypeConverter.supportsResultLookupKeys.
The function starts with the initial value and a sourceLookupKey (if applicable), trying to apply a converter that can handle this input. If successful, it checks if the output format matches the desired resultLookupKey. If not, it recursively attempts to find and apply a subsequent converter that can take this intermediate result closer to the target lookup key. This process repeats until either the target lookup key is achieved, or no suitable converter can be found.
A DataTypeConverter can return values with these use cases:
A ConversionResult object is created and updated throughout this process to track the progress of the conversion, including any intermediate results obtained. If at any point a converter successfully processes the value, the ConversionResult.earlierResult property is updated, signaling that a valid conversion path exists up to that point. This property is used by callers of this function to determine whether a successful conversion chain has been established, and they should join in the chain.
Exception handling for the conversion process is managed by the caller, specifically by the convertUntilResult function, to centralize error management and streamline the recursive logic. We want a failure deep in the recursion to bubble up to the top level, where it can be logged. We also want to retain the converter that failed. So we modify the Error object to include it in a property called 'converter'.
Design note: This function travels deep first, going down a path until its either the right one or proven wrong. It then backtracks to try another path. In a multithreaded language, this would be better implemented as a breadth-first search. using threads.
The value to be converted.
The lookup key of the source format, or null if not applicable.
The lookup key of the target format to achieve through conversion.
Intermediate lookup key used in recursive calls to track progress.
Lookup keys already checked, to avoid redundant conversions.
A ConversionResult object detailing the outcome of the conversion attempt.
Gets the first IDataTypeConverter that supports the value, or null if none are found. Runs the lazyloader if setup and the first search fails.
Finds all that support both the value and the sourceLookupKey parameter. The caller can then use the supportedResultLookupKeys to build an exact match test for the find() function.
Protected
logLogs the conversion result for a successful conversion.
The conversion result to log.
Protected
logLogs a conversion that resulted in undefined, meaning the converter was valid but the input value was not.
The conversion result containing information about the failed conversion.
Protected
addAdds a path property to result with all valid steps followed but only if there was more than one step.
Protected
logLogs a warning message when a DataTypeConverter is needed but not found.
The ConversionResult object.
The source value that needs to be converted.
Protected
logLogs a message indicating that there is nothing to convert because the value is null or undefined.
The ConversionResult object.
Protected
logLogs the error result.
The conversion result.
Protected
logProtected
updateChanges the services on all implementations of IServicesAccessor
Registers an instance of the interface supported by this service. It may replace an existing one, as determined by the subclass. Replace supported on: IDataTypeIdentifier
Protected
unregisterReturns the full collection.
Protected
ensureProtected
logProtected
hasGenerated using TypeDoc v0.25.12
A service for changing the original value into something that you want a condition to evaluate using IDataTypeConverter instances.
This is essential for comparison Conditions. Comparison works automatically with string, number, and boolean native types. Converters exist to take a Date or user defined class to a string, number, or boolean. They are built on IDataTypeConverter.