import { InterceptorConfig } from '../InterceptorConfig';
import { registerInterceptor } from '../InterceptorGenerator';
import { InterceptorHandler } from '../InterceptorHandler';
export class ModifierRegexCharRemover extends InterceptorConfig {
  constructor(regex) {
    super('modifierNonAlphanumericCharRemover');
    this.regex = regex;
  }
}
ModifierRegexCharRemover.id = 'modifierNonAlphanumericCharRemover';
export class ModifierRegexCharRemoverHandler extends InterceptorHandler {
  constructor(config) {
    super();
    this.config = config;
  }
  run(_context, _values, _field, value) {
    if (typeof value === 'string' || value instanceof String) {
      return {
        value: value.replace(new RegExp(this.config.regex, "gm"), ''),
      };
    }
    return { value };
  }
}
registerInterceptor(ModifierRegexCharRemover.id, (config) => new ModifierRegexCharRemoverHandler(config));
