A ValueHost that supports input validation, meaning the value from the user's input, such as from a textbox or tag.

There are two types of values associated with an InputValueHost:

  • input value - the value supplied by the input field/element. It is often a string representation of the native data and may contain errors preventing its conversion into that native data. Only a few conditions evaluate the input value, but they are important: RequireTextCondition, DataTypeCheckCondition and RegExpCondition.
  • native value - the value that will be stored in the Model. Date object, number, boolean, and your own object are examples. When the native type is a string, it is often similar in both input and native values. The string in the native value may be cleaned up, trimmed, reformatted, etc. Most Conditions evaluate the native value.

Its up to the system consumer to manage both.

  • When an input has its value set or changed, also assign it here with setInputValue().
  • RequireTextCondition, DataTypeCheckCondition and RegExpCondition look at the InputValue via getInputValue().
  • The initial native value is assigned with setValue. The consumer handles converting the input field/element value into its native value and supplies it with setValue or setValueUndetermined.
  • Most Conditions look at the native value through getValue.
interface IInputValueHost {
    requiresInput: boolean;
    isValid: boolean;
    validationStatus: ValidationStatus;
    asyncProcessing: boolean;
    currentValidationState: ValueHostValidationState;
    doNotSave: boolean;
    corrected: boolean;
    isChanged: boolean;
    valueHostsManager: IValueHostsManager;
    dispose(): void;
    getInputValue(): any;
    setInputValue(value, options?): void;
    setValues(nativeValue, inputValue, options?): void;
    getConversionErrorMessage(): null | string;
    getParserLookupKey(): undefined | null | string;
    otherValueHostChangedNotification(valueHostIdThatChanged, revalidate): void;
    validate(options?): null | ValueHostValidateResult;
    clearValidation(options?): boolean;
    setBusinessLogicError(error, options?): boolean;
    clearBusinessLogicErrors(options?): boolean;
    getIssueFound(errorCode): null | IssueFound;
    getIssuesFound(group?): null | IssueFound[];
    setIssuesFound(issuesFound, behavior): boolean;
    getValidator(errorCode): null | IValidator;
    getName(): string;
    getLabel(): string;
    getValue(): any;
    setValue(value, options?): void;
    setValueToUndefined(options?): void;
    getDataType(): null | string;
    saveIntoInstanceState(key, value): void;
    getFromInstanceState(key): undefined | ValidTypesForInstanceStateStorage;
    getDataTypeLabel(): string;
    isEnabled(): boolean;
    setEnabled(enabled): void;
    gatherValueHostNames(collection, valueHostResolver): void;
}

Hierarchy (view full)

Implemented by

Properties

requiresInput: boolean

Returns true for a condition with Category=Require. UI can use it to display a "requires a value" indicator.

isValid: boolean

Value is setup by calling validate(). It does not run validate() itself. Returns false when instanceState.status is Invalid. Any other instanceState.status return true. This follows an old style validation rule of everything is valid when not explicitly marked invalid. That means when it hasn't be run through validation or was undetermined as a result of validation. Recommend using doNotSave for more clarity.

validationStatus: ValidationStatus

Status from the latest validation, or an indication that validation has yet to occur. It is changed internally and can influence how validation behaves the next time. Prior to calling validate() (or setValue()'s validate option), it is NotAttempted. After setValue it is NeedsValidation. After validate, it may be Valid, Invalid or Undetermined.

asyncProcessing: boolean

When true, an async Validator is running

currentValidationState: ValueHostValidationState

Exposes the current validation state for the ValueHost. It combines other properties and issuesFound. The same value is delivered to the onValueHostValidationStateChanged callback.

doNotSave: boolean

Determines if a validator doesn't consider the ValueHost's value ready to save. True when ValidationStatus is Invalid or NeedsValidation.

corrected: boolean

Set to true when the user has fixed all invalid validators. Undefined or false otherwise, including if the status changes after this point.

isChanged: boolean

Determines how the validation system sees the Value in terms of editing. When true, it was changed. When false, it was not. The setValue() and related functions are the only ones to change this flag. They all set it to true automatically except set it to false when the option.Reset is true. The ValidatableValueHost.validate() function may skip validation of a ValueHost when isChanged is false, depending on the options for validate(). For example, calling validate immediately after loading up the form, you want to avoid showing Category=Require validators. Those should appear only if the user edits, or when the user attempts to submit.

valueHostsManager: IValueHostsManager

Methods

  • If the user needs to abandon this instance, they should use this to clean up active resources (like timers) and to release memory that would stall the garbage collector from disposing this object. It should assign any object reference to undefined as a strong indicator that the object has been disposed.

    Returns void

  • Exposes the latest value retrieved from the input field/element exactly as supplied by the input. For example, an returns a string, not a date. Strings are not cleaned up, no trimming applied.

    Returns any

  • System consumer assigns the value it also assigns to the input field/element. Its used with RequireTextCondition, DataTypeCheckCondition and RegExpCondition.

    Parameters

    • value: any
    • Optional options: SetInputValueOptions

      validate - Invoke validation after setting the value. Reset - Clears validation (except when validate=true) and sets isChanged to false. ConversionErrorTokenValue - When setting the value to undefined, it means there was an error converting. Provide a string here that is a UI friendly error message. It will appear in the Category=Require validator within the {ConversionError} token.

    Returns void

  • Sets both (native data type) Value and Input Value at the same time and optionally invokes validation. Use when the consuming system resolves both input field/element and native values at the same time so there is one state change and attempt to validate.

    Parameters

    • nativeValue: any

      Can be undefined to indicate the value could not be resolved from the inputs's value, such as inability to convert a string to a date. All other values, including null and the empty string, are considered real data.

    • inputValue: any

      Can be undefined to indicate there is no value. All other values, including null and the empty string, are considered real data.

    • Optional options: SetValueOptions

      validate - Invoke validation after setting the value. Reset - Clears validation (except when validate=true) and sets IsChanged to false. ConversionErrorTokenValue - When setting the value to undefined, it means there was an error converting. Provide a string here that is a UI friendly error message. It will appear in the Category=Require validator within the {ConversionError} token.

    Returns void

  • Returns the ConversionErrorTokenValue supplied by the latest call to setValue() or setValues(). Its null when not supplied or has been cleared. Associated with the {ConversionError} token of the DataTypeCheckCondition.

    Returns null | string

  • Runs validation against some of all validators. If at least one validator was NoMatch, it returns ValueHostValidateResult with all of the NoMatches in issuesFound. If all were Matched, it returns ValueHostValidateResult.Value and issuesFound=null. If there are no validators, or all validators were skipped (disabled), it returns ValidationStatus.Undetermined. Updates this ValueHost's InstanceState and notifies parent if changes were made.

    Parameters

    Returns null | ValueHostValidateResult

    Non-null when there is something to report. null if there was nothing to evaluate which includes all existing validators reporting "Undetermined"

  • When Business Logic gathers data from the UI, it runs its own final validation. If its own business rule has been violated, it should be passed here where it becomes exposed to the Validation Summary (getIssuesFound) and optionally for an individual ValueHostName, by specifying that valueHostName in AssociatedValueHostName. Each time called, it adds to the existing list. Use clearBusinessLogicErrors() first if starting a fresh list.

    Parameters

    • error: BusinessLogicError

      A business logic error to show. If it has an errorCode assigned and the same errorCode is already recorded here, the new entry replaces the old one.

    • Optional options: ValidateOptions

      Only supports the skipCallback option.

    Returns boolean

    true when a change was made to the known validation state.

  • A list of all issues found.

    Parameters

    • Optional group: string

      Omit or null to ignore groups. Otherwise this will match to Validatable ValueHosts with the same group (case insensitive match).

    Returns null | IssueFound[]

    An array of issues found. When null, there are no issues and the data is valid. If there are issues, when all have severity = warning, the data is also valid. Anything else means invalid data. Each contains:

    • name - The name for the ValueHost that contains this error. Use to hook up a click in the summary that scrolls the associated input field/element into view and sets focus.
    • severity - Helps style the error. Expect Severe, Error, and Warning levels.
    • errorMessage - Fully prepared, tokens replaced and formatting rules applied, to show in the Validation Summary widget. Each Validator has 2 messages. One is for Summary only. If that one wasn't supplied, the other (for local displaying message) is returned.
  • Adds or replaces all IssueFound items that are associated with this ValueHost. It ignores those with another ValueHost name, allowing for the same list to be culled by all ValueHosts. (As a result, it never changes the values sent in, or the array itself.) Replacement when the errorCode is the same. Always invokes the onValueHostValidationStateChanged callback.

    Use case: client-side getting server-side Jivs-generated IssuesFound, so the UI can incorporate it.

    Parameters

    Returns boolean

  • Replaces the value and optionally validates. Call when the value was changed in the system consumer.

    Parameters

    • value: any

      Can be undefined to indicate the value could not be resolved from the input field/element's value, such as inability to convert a string to a date. All other values, including null and the empty string, are considered real data. When undefined, IsChanged will still be changed to true unless options.Reset = true.

    • Optional options: SetValueOptions

      validate - Invoke validation after setting the value. Reset - Clears validation (except when validate=true) and sets IsChanged to false. ConversionErrorTokenValue - When setting the value to undefined, it means there was an error converting. Provide a string here that is a UI friendly error message. It will appear in the Category=Require validator within the {ConversionError} token.

    Returns void

  • Identifies that the value is undetermined. For example, the user's input cannot be converted into its native data type or the input is empty. Note this does not reset IsChanged to false without explicitly specifying options.Reset = true;

    Parameters

    • Optional options: SetValueOptions

      validate - Invoke validation after setting the value. Reset - Clears validation (except when validate=true) and sets IsChanged to false. ConversionErrorTokenValue - When setting the value to undefined, it means there was an error converting. Provide a string here that is a UI friendly error message. It will appear in the Category=Require validator within the {ConversionError} token.

    Returns void

  • Determines if the ValueHost is enabled for user interaction. It is enabled unless you explicilty set it to false using ValueHostConfig.initialEnabled : false, setup the EnablerCondition which determines when it is enabled, or the ValueHost's own setEnabled() function.

    When disabled, the data values of the ValueHost do not get changed by setValue() and related functions. However, those functions offer the overrideDisabled option to force the change.

    When disabled and the ValueHost have validators, all validation is disabled and its ValidationStatus reports ValidationState.Disabled.

    Returns boolean

  • Sets the enabled state of the ValueHost. When false, the ValueHost is disabled and setValue() and related functions will not change the value. However, they offer the overrideDisabled option to force the change. When disabled and the ValueHost has validators, all validation is disabled and its ValidationStatus reports ValidationState.Disabled.

    This value is part of the ValueHost's InstanceState, not the Config, although the ValueHostConfig.initialEnabled is used when it is not set in the state.

    Parameters

    • enabled: boolean

    Returns void

Generated using TypeDoc v0.25.12