setErrorClasses(elements, dirty, hasErrors, hasMessages, element = this.element) {
    this.clearErrorClasses();
    elements.forEach((element) => {
      this.setElementInvalid(this.performInputMapping(element), false);
    });
    this.setInputWidgetErrorClasses(elements, hasErrors);
    // do not set error classes for hidden components
    if (!this.visible) {
      return;
    }

    if (hasErrors) {
      // Add error classes
      elements.forEach((input) => {
        this.setElementInvalid(this.performInputMapping(input), true);
      });

      if (dirty && this.options.highlightErrors) {
        this.addClass(element, this.options.componentErrorClass);
      }
      else {
        this.addClass(element, 'has-error');
      }
    }
    if (hasMessages) {
      this.addClass(element, 'has-message');
    }
  }
Sets the form input widget error classes.
@param {Array<HTMLElement>} elements - An array of DOM elements to set the error classes on.
@param {boolean} dirty - If the input is dirty.
@param {boolean} hasErrors - If the input has errors.
@param {boolean} hasMessages - If the input has messages.
@param {HTMLElement} element - The wrapper element for all the other elements passed in first argument.
@returns {void}