Skip to content
Snippets Groups Projects

Dto service

Merged Ghost User requested to merge dto-service into piirto2
1 file
+ 20
0
Compare changes
  • Side-by-side
  • Inline
@@ -30,3 +30,23 @@ export class RoleValidation implements ValidatorConstraintInterface {
@@ -30,3 +30,23 @@ export class RoleValidation implements ValidatorConstraintInterface {
return 'Not valid uuid';
return 'Not valid uuid';
}
}
}
}
 
 
// checks for valid JSON for center
 
@ValidatorConstraint({ name: 'centerJSON', async: true })
 
export class CenterJSON implements ValidatorConstraintInterface {
 
validate(center: JSON, args: ValidationArguments) {
 
const validator = new Validator();
 
return (
 
validator.isNumber(center['lat']) &&
 
validator.isNumber(center['lng']) &&
 
validator.min(center['lat'], -90) &&
 
validator.max(center['lat'], 90) &&
 
validator.min(center['lng'], -180) &&
 
validator.max(center['lng'], 180)
 
);
 
}
 
 
defaultMessage(args: ValidationArguments) {
 
return 'Error with center JSON';
 
}
 
}
Loading