import type { ObservableSet } from 'mobx';
import { observable } from 'mobx';
import type { RemoveError } from './types';

export default class ValidationHelper {
  errors: ObservableSet<RemoveError>;

  constructor() {
    this.errors = observable.set();
  }

  add = (removeError: RemoveError) => {
    this.errors.add(removeError);
  };

  removeErrors = () => {
    this.errors.forEach((removeError) => removeError());
    this.errors.clear();
  };
}
