import template from './ws-validation-messages.tmpl.html';
import WsValidationMessagesController from './ws-validation-messages.controller';

/**
  * Validation messages can be set either through:
  * Option 1: Manually set $ctrl.model.errors[attribute]
  * to an array of displayable error strings.
  * Only first error sring will be displayed.
  * Option 2: Let $ctrl.formName.$error be used automatically
  */

const WsValidationMessagesComponent = {
  template,
  transclude: true,
  controller: WsValidationMessagesController,
  bindings: {
    // The overall model that contains the value being validated and the errors object
    model: '<',
    // The form for the field
    formName: '<',
    // The key for the particular field on the form model
    attribute: '@',
    // Whether to display errors before the form has been touched
    forceErrors: '<?',
  },
};

export default WsValidationMessagesComponent;
