Abstraction for easy managing of validation of some form. This class uses a Vue instance with configured Vuelidate state to provide reactivity of form data.

# new Validator ()

Methods

# initializeWithCustomOptions (params:  object, customValidationMixinopt:  Vue) static

Create a instance for form data validation based on some options defined as Vue mixin. Default behavior is to check entity schema attributes with allowNull=true and defaultView=true.

customValidationMixin can extend default behavior by it own rules.

Arguments:
  • params: object
    • store:  Vuex

      Store

    • entitySchema:  UBEntity

      Entity schema

    • masterFieldList:  Array.<string>

      Field list of master entity

  • customValidationMixin = {}: Vue

    Custom validations what extends default

# getAttributeCaption (attributeName:  string) → string instance

Get caption by attribute name from attributeCaptions sections. If it is not defined, default locale i18n(${entity}.${attributeName}) will be returned

Arguments:

# getErrorForAttribute (attributeName:  string) → string | null instance

Get error text for some first failed validation rule of the attribute

Arguments:

# getIsAttributeRequired (attributeName:  string) → boolean instance

Check if the attribute has the required rule in the configured validation

Arguments:

# getValidationState () → object instance

Returns the current state of validation. The method is useful when you have dynamic validation

Return:

Vuelidate object

# reset () instance

Reset validation state

# validateForm (paramsopt:  object) instance

Validates form data with the Vuelidate help. If validation is failed UBAbortError will be thrown

Arguments:
  • params = {}: object
    • showErrorModal=true:  boolean

      To display error modal if validation is failed

    • errorMsgTemplate='validationError':  string

      Error message template for the error modal