export class VerificationError extends Error {
   constructor(
      public readonly type?: string,
      public readonly field?: string,
      public readonly value?: any
   ) {
      super("Parameter verification failed! " +(type ? "Expected " + type + "! " :"") + (field ? "At: " + field + "! " : ""));
   }
}

export function apply_number(data: any) {
   data = Number(data);
   if(Number.isNaN(data)) throw new VerificationError("number", undefined, data);
   return data;
}

export function apply_string(data: any) {
   return String(data);
}

export function apply_boolean(data: any) {
   return Boolean(data);
}

export function apply_void(data: any) {}
