Class ValidatableValueHostBase<TConfig, TState>Abstract

Expands upon ValueHost to provide the basics of validation.

Type Parameters

Hierarchy (view full)

Implements

Constructors

Accessors

  • get isValid(): boolean
  • Value is setup by calling validate(). It does not run validate() itself. Returns false when instanceState.status is Invalid. Any other ValidationStatus 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.

    Returns boolean

  • get 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()/setInputValue()/setValues() 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 ValueHost.validate() function may skip validation of an InputValueHost 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.

    Returns boolean

Methods

  • System consumer assigns the native value to make it available to most Conditions during validation.

    Parameters

    • value: any
    • 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

  • When the ValueHost is disabled, it clears any validation issues. A call to validate() will return null until the ValueHost is enabled again. If the Enabler condition changes the state to enabled, it remains up to the user to call validate() again to get the new state. While disabled, some validation activity can still happen:

    • BusinessLogicErrors can be set, but will not be available with getIssuesFound() until the ValueHost is enabled again.
    • The onValueHostValidationStateChanged event will be raised on actions that change the state, such as setting a BusinessLogicError. Otherwise all calls to get ValidationStatus will act as if the ValueHost has no errors, except for ValidationState which is set to Disabled.

    Parameters

    • enabled: boolean

    Returns void

  • Runs validation against some of all validators. If at least one validator was NoMatch, it returns IValidatorInstanceStateDictionary with all of the NoMatches. If all were Matched or Undetermined, it returns null indicating validation isn't blocking saving the data. Updates this ValueHost's InstanceState and notifies parent if changes were made. *

    Parameters

    • Optional options: ValidateOptions

      Provides guidance on which validators to include. *

    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"
  • Determines if the group supplied is a match for the group setup on this ValueHost.

    Parameters

    • requestedGroup: undefined | null | string
    • fromLastValidation: boolean

      Source of this instance's group is either the original configuration or the value of the last validation. WHen true, from the last validation.

    Returns boolean

  • 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. It calls onValueHostValidationStateChanged if there was a changed to the state.

    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

    Returns boolean

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

  • Helper to call onValueHostValidationStateChanged due to a change in the state associated with Validate itself or BusinessLogicErrors. It also asks ValidationManager to call onValidationStateChanged so observers that only watch for validation from a high level will be notified.

    This may still be called when the ValueHost is disabled, so long as an underlying state has changed. The call to setEnabled(false) itself calls clearValidation() which usually triggers this event allow the UI to know to handle the discarded valuehost's validation data.

    Parameters

    Returns void

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

    Parameters

    • Optional group: 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.
  • 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. This call invokes the onValueHostValidationStateChanged callback if there were IssueFound items applied.

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

    Parameters

    Returns boolean

  • Consuming system calls this when it attempts to resolve the input field/element value but cannot. It identifies that the native value is undefined. 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

  • Use to change anything in ValueHostInstanceState without impacting the immutability of the current instance. Your callback will be passed a cloned instance. Change any desired properties and return that instance. It will become the new immutable value of the InstanceState property. If changes were made, the OnValueHostInstanceStateChanged event is fire.

    Parameters

    Returns boolean

    true when the state did change. false when it did not.

Generated using TypeDoc v0.25.12