export abstract class RequestValidator {
  protected abstract propsNonAuthorisees?: string[];

  constructor(protected errMsg?: string) {}

  validate = (obj: any) => {
    const validationResult = null;

    if (validationResult?.error) {
      const allErrors = validationResult.error.details.map(
        (error) => error.message,
      );
      throw new Error(this.errMsg ? this.errMsg : allErrors.join(', '));
    } else {
      return this.sanitizeObject(validationResult.value);
    }
  };

  sanitizeObject = (obj: any) => {
    if (this.propsNonAuthorisees) {
      this.propsNonAuthorisees.forEach((prop) => {
        if (obj[prop] !== undefined) {
          delete obj[prop];
        }
      });
    }

    return obj;
  };
}
