Skip to content
Snippets Groups Projects

Dto service

Merged Ghost User requested to merge dto-service into piirto2
3 files
+ 15
19
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 0
17
import {ValidatorConstraint, ValidatorConstraintInterface, ValidationArguments} from "class-validator";
import { Logger } from "@nestjs/common";
// validates array length
@ValidatorConstraint({ name: "arrayLength", async: true })
export class ArrayLength implements ValidatorConstraintInterface {
validate(array: string[], args: ValidationArguments) {
Logger.log(array.length)
return array.length > args.constraints[0] && array.length < args.constraints[1]; // for async validations you must return a Promise<boolean> here
}
defaultMessage(args: ValidationArguments) { // here you can provide default error message if validation failed
return "Please input all passwords";
}
}
\ No newline at end of file
Loading