An API of methods and properties for forms on a multiple value control.

interface SmiMultiValueControlFormApi {
    addValidator(validator: (() => null | {
        [errorName: string]: string;
    }), typeAttribute?: string): (() => void);
    getErrors(typeAttribute?: string): null | {
        [error: string]: string;
    };
    getValidationMessageId(): undefined | string;
    isDirty(typeAttribute?: string): boolean;
    isInvalid(typeAttribute?: string): boolean;
    isTouched(typeAttribute?: string): boolean;
    isValid(typeAttribute?: string): boolean;
    markAllAsTouched(): void;
    markAsDirty(typeAttribute?: string): void;
    markAsPristine(typeAttribute?: string): void;
    markAsTouched(typeAttribute?: string): void;
    onShowInvalidChange(callback: ((showInvalid: boolean) => void), typeAttribute?: string): (() => void);
    onValidityChange(callback: ((valid: boolean) => void), typeAttribute?: string): (() => void);
    reset(typeAttribute?: string): void;
    setErrors(errors: null | {
        [error: string]: string;
    }, typeAttribute?: string): void;
    showInvalid(typeAttribute?: string): boolean;
}

Methods

  • Adds a validator function to the control. Returns an error object, or null if there are no errors. to the control.

    Parameters

    • validator: (() => null | {
          [errorName: string]: string;
      })

      The validator function to add.

        • (): null | {
              [errorName: string]: string;
          }
        • Returns null | {
              [errorName: string]: string;
          }

    • OptionaltypeAttribute: string

      The type attribute with which the form control is associated.

    Returns (() => void)

    A function that removes the validator.

      • (): void
      • Returns void

  • Returns all errors for the control.

    Parameters

    • OptionaltypeAttribute: string

      The type attribute with which the form control is associated.

    Returns null | {
        [error: string]: string;
    }

    An object containing the errors or null.

  • Gives the ID of the element that is showing a validation message for the control. Returns the ID for the element that is showing a validation message for the control. Returns undefined if there is no message shown.

    Returns undefined | string

    The id of the element that is showing a validation message for the control or returns undefined if there is no message being shown.

  • Returns whether the control is dirty. A control is dirty after the user has changed the value of the control.

    Parameters

    • OptionaltypeAttribute: string

      The type attribute with which the form control is associated.

    Returns boolean

    A boolean value describing if the control is dirty.

  • Gives whether the control is invalid.

    Parameters

    • OptionaltypeAttribute: string

      The type attribute with which the form control is associated.

    Returns boolean

    A boolean value describing if the control is invalid.

  • Returns whether the control is touched. A control is touched after the user has triggered a blur event on it.

    Parameters

    • OptionaltypeAttribute: string

      The type attribute with which the form control is associated.

    Returns boolean

    A boolean value describing if the control has been touched.

  • Returns whether the control is valid.

    Parameters

    • OptionaltypeAttribute: string

      The type attribute with which the form control is associated.

    Returns boolean

    A boolean value describing if the control is valid.

  • Marks the control and all its descendant controls as touched.

    Returns void

  • Marks the control as dirty.

    Parameters

    • OptionaltypeAttribute: string

      The type attribute with which the form control is associated.

    Returns void

  • Marks the control as pristine.

    Parameters

    • OptionaltypeAttribute: string

      The type attribute with which the form control is associated.

    Returns void

  • Marks the control as touched.

    Parameters

    • OptionaltypeAttribute: string

      The type attribute with which the form control is associated.

    Returns void

  • Runs a callback when the the control's show invalid state changes.

    Parameters

    • callback: ((showInvalid: boolean) => void)
        • (showInvalid): void
        • Parameters

          • showInvalid: boolean

          Returns void

    • OptionaltypeAttribute: string

      The type attribute with which the form control is associated.

    Returns (() => void)

    A function that removes the callback.

      • (): void
      • Returns void

  • Runs a callback when the the control's validity changes.

    Parameters

    • callback: ((valid: boolean) => void)

      A callback that is invoked with the valid state.

        • (valid): void
        • Parameters

          • valid: boolean

          Returns void

    • OptionaltypeAttribute: string

      The type attribute with which the form control is associated.

    Returns (() => void)

    A function that removes the callback.

      • (): void
      • Returns void

  • Resets the form control, marking it pristine and untouched.

    Parameters

    • OptionaltypeAttribute: string

      The type attribute with which the form control is associated.

    Returns void

  • Sets the given error on the control.

    Parameters

    • errors: null | {
          [error: string]: string;
      }

      The errors object.

    • OptionaltypeAttribute: string

      The type attribute with which the form control is associated.

    Returns void

  • Returns whether the control should show itself as being invalid.

    Parameters

    • OptionaltypeAttribute: string

      The type attribute with which the form control is associated.

    Returns boolean

    A boolean value indicating whether the control should show itself as being invalid.