Skip to content
Snippets Groups Projects
Commit e5a62911 authored by L4168's avatar L4168
Browse files

added validation for centerJSON

parent e3383200
No related branches found
No related tags found
4 merge requests!59Development to master,!31Development,!26Piirto2,!25Dto service
......@@ -30,3 +30,23 @@ export class RoleValidation implements ValidatorConstraintInterface {
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';
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment