import { FileValidator, getLengthValidator, getCommitmentValidator } from './validator';
// Thanks to @Sébastien.Lubineau https://medium.com/@sebastien.lubineau/input-validation-with-stenciljs-f464644545c8
export var ValidatorsName;
(function (ValidatorsName) {
  ValidatorsName["file"] = "file";
  ValidatorsName["length"] = "length";
  ValidatorsName["commitment"] = "commitment";
})(ValidatorsName || (ValidatorsName = {}));
export const defaultValidator = {
  validate: (_x) => true
};
export function getValidator(v) {
  if (typeof v === 'string') {
    return validatorFactory(v, null);
  }
  else if (typeof v === 'object' && (v.name === 'length' || v.name === 'file' || v.name === 'commitment')) {
    return validatorFactory(v.name, v.options);
  }
}
// simple controller for handling our typed validators
export function validatorFactory(name, options) {
  options ? options : {};
  switch (name) {
    case (ValidatorsName.file):
      return FileValidator(options);
    case (ValidatorsName.length):
      return getLengthValidator(options.min, options.max);
    case (ValidatorsName.commitment):
      return getCommitmentValidator(options.min);
    default:
      return defaultValidator;
  }
}
