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 (paramsobject, customValidationMixinoptVue) 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
  • customValidationMixin = {}: Vue

    Custom validations what extends default

# getAttributeCaption (attributeNamestring) → 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 (attributeNamestring) → string | null instance

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

Arguments:

# getIsAttributeRequired (attributeNamestring) → 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 (paramsoptobject) instance

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

Arguments:
  • params = {}: object
    • showErrorModal=trueboolean

      To display error modal if validation is failed

    • errorMsgTemplate='validationError'string

      Error message template for the error modal