text: "use strict";
  /**
   * @module indicative-formatters
   */
  Object.defineProperty(exports, "__esModule", { value: true });
  /**
   * Vanilla formatter is a plain formatter to collect validation
   * errors
   */
  class VanillaFormatter {
      constructor() {
          this.errors = [];
      }
      /**
       * Adds error to the list of existing errors
       */
      addError(error, field, rule) {
          let message = '';
          let validation = rule;
          if (error instanceof Error) {
              message = error.message;
              validation = 'ENGINE_EXCEPTION';
          }
          else {
              message = error;
          }
          this.errors.push({ message, validation, field });
      }
      /**
       * Returns an array of errors or `null` when there are no
       * errors
       */
      toJSON() {
          return this.errors.length ? this.errors : null;
      }
  }
  exports.VanillaFormatter = VanillaFormatter;
  