Interface from which to implement a ValidationManager.

interface IValidationManager {
    services: IValidationServices;
    isValid: boolean;
    doNotSave: boolean;
    asyncProcessing?: boolean;
    vh: IValueHostAccessor;
    dispose(): void;
    startModifying(): ValidationManagerConfigModifier;
    getValidatorsValueHost(valueHostName): null | IValidatorsValueHostBase;
    getInputValueHost(valueHostName): null | IInputValueHost;
    getPropertyValueHost(valueHostName): null | IPropertyValueHost;
    validate(options?): ValidationState;
    clearValidation(options?): boolean;
    setBusinessLogicErrors(errors, options?): boolean;
    getIssuesForInput(valueHostName): null | IssueFound[];
    getIssuesFound(group?): null | IssueFound[];
    setIssuesFound(issuesFound, behavior): boolean;
    notifyValidationStateChanged(validationState, options?, force?): void;
    getValueHost(valueHostName): null | IValueHost;
    getCalcValueHost(valueHostName): null | ICalcValueHost;
    getStaticValueHost(valueHostName): null | IStaticValueHost;
    enumerateValueHosts(filter?): Generator<IValueHost, any, unknown>;
    addValueHost(config, initialState): IValueHost;
    addOrUpdateValueHost(config, initialState): IValueHost;
    addOrMergeValueHost(config, initialState): IValueHost;
    discardValueHost(valueHostName): void;
    notifyOtherValueHostsOfValueChange(valueHostIdThatChanged, revalidate): void;
    notifyValueHostInstanceStateChanged(valueHost, instanceState): void;
}

Hierarchy (view full)

Implemented by

Properties

Provides access to ValidationServices (override IServices).

isValid: boolean

When true, the current state of validation does not know of any errors. However, there are other factors to consider: there may be warning issues found (in IssuesFound), an async validator is still running, validator evaluated as Undetermined. So check doNotSaveValueHosts as the ultimate guide to saving. When false, there is at least one validation error.

doNotSave: boolean

Determines if a validator doesn't consider the ValueHost's value ready to save based on the latest call to validate(). (It does not run validate().) True when at least one ValueHost's ValidationStatus is Invalid or NeedsValidation

asyncProcessing?: boolean

When true, an async Validator is running

Alternative to getValueHost() and companion functions that returns strongly typed valuehosts in a shortened syntax. Always throws exceptions if the value host requested is unknown or not the expected type.

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

  • Runs validation against all validatable ValueHosts, except those that do not match the validation group supplied in options. Updates this ValueHost's InstanceState and notifies parent if changes were made.

    Parameters

    • Optional options: ValidateOptions

      Provides guidance on which validators to include. Important to set options.BeforeSubmit to true if invoking validate() prior to submitting.

    Returns ValidationState

    The ValidationState object, which packages several key pieces of information: isValid, doNotSave, and issues found.

  • 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 its called, all previous business logic errors are abandoned.

    Parameters

    • errors: null | BusinessLogicError[]

      A list of business logic errors to show or null to indicate no errors.

    • Optional options: ValidateOptions

      Only considers the skipCallback option.

    Returns boolean

    when true, the validation snapshot has changed.

  • Lists all issues found (error messages and supporting info) for a single ValidatorsValueHostBase so the input field/element can show error messages and adjust its appearance.

    Parameters

    • valueHostName: string

    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.
    • errorCode - Identifies the validator supplying the issue.
    • severity - Helps style the error. Expect Severe, Error, and Warning levels.
    • errorMessage - Fully prepared, tokens replaced and formatting rules applied
    • summaryMessage - The message suited for a Validation Summary widget.
  • A list of all issues from all ValidatorsValueHostBases optionally for a given group. Use with a Validation Summary widget and when validating the Model itself.

    Parameters

    • Optional group: string

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

    Returns null | IssueFound[]

    An array of details 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.
    • errorCode - Identifies the validator supplying the issue.
    • severity - Helps style the error. Expect Severe, Error, and Warning levels.
    • errorMessage - Fully prepared, tokens replaced and formatting rules applied.
    • summaryMessage - The message suited for a Validation Summary widget.
  • Adds or replaces all IssueFound items to the appropriate ValueHosts. Each ValueHost will invoke the onValueHostValidationStateChanged callback if needed.

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

    Parameters

    Returns boolean

  • ValueHosts that validate should try to fire onValidationStateChanged, even though they also fire onValueHostValidationStateChanged. This allows systems that observe validation changes at the validationManager level to know. This function is optionally debounced with a delay in ms coming from ValidationManagerConfig.notifyValidationStateChangedDelay

    Parameters

    • validationState: null | ValidationState
    • Optional options: ValidateOptions
    • Optional force: boolean

      when true, override the debouncer and execute immediately.

    Returns void

  • Adds a ValueHostConfig for a ValueHost not previously added. Does not trigger any notifications. Exception when the same ValueHostConfig.name already exists.

    Parameters

    • config: ValueHostConfig

      Can use builder.static(), builder.calc() or any ValueConfigHost. (builder is the Builder API)

    • initialState: null | ValueHostInstanceState

      When not null, this state object is used instead of an initial state. It overrides any state supplied by the ValueHostsManager constructor. It will be run through ValueHostFactory.cleanupInstanceState() first. When null, the state supplied in the ValueHostsManager constructor will be used if available. When neither state was supplied, a default state is created.

    Returns IValueHost

  • Replaces a ValueHostConfig for an already added ValueHost. It does not merge. If merging is required, use addOrMergeValueHost(). Does not trigger any notifications. If the name isn't found, it will be added. Any previous ValueHost and its config will be disposed. Be sure to discard any reference to the ValueHost instance that you have.

    Parameters

    • config: ValueHostConfig

      Can use builder.static(), builder.calc() or any ValueConfigHost. (builder is the Builder API)

    • initialState: null | ValueHostInstanceState

      When not null, this state object is used instead of an initial state. It overrides any state supplied by the ValueHostsManager constructor. It will be run through ValueHostFactory.cleanupInstanceState() first.

    Returns IValueHost

  • Replaces a ValueHostConfig for an already added ValueHost. It merges the new config with the existing one using the ValueHostConfigMergeService. The goal is to protect important business logic settings while allowing the UI to inject new property values where appropriate. Does not trigger any notifications. If the name isn't found, it will be added. Any previous ValueHost and its config will be disposed. Be sure to discard any reference to the ValueHost instance that you have.

    Parameters

    • config: ValueHostConfig

      Can use builder.static(), builder.calc() or any ValueConfigHost. (builder is the Builder API)

    • initialState: null | ValueHostInstanceState

      When not null, this state object is used instead of an initial state. It overrides any state supplied by the ValueHostsManager constructor. It will be run through ValueHostFactory.cleanupInstanceState() first.

    Returns IValueHost

Generated using TypeDoc v0.25.12