import { Injectable, PipeTransform } from '@nestjs/common'; import { RESTError } from '../models/wrappers/rest-wrapper.class'; import { isNumberString, isString, length } from 'class-validator'; @Injectable() export class ValidatePIDPipe implements PipeTransform { transform(value: string): string { const checkNumberString = isNumberString(value); const checkLength = length(value, 11, 11); if (checkNumberString && checkLength) { return value; } else { throw new RESTError('INVALID_PID', value); } } }