Skip to content
Snippets Groups Projects
Commit 70065774 authored by michael.minelli's avatar michael.minelli
Browse files

Validators => Rename array to json san. + Add enonce validator

parent 11a83ca8
No related branches found
No related tags found
No related merge requests found
......@@ -49,7 +49,7 @@ class DojoValidators {
}
});
readonly arraySanitizer = this.toValidatorSchemaOptions({
readonly jsonSanitizer = this.toValidatorSchemaOptions({
options: (value, {
req,
location,
......@@ -101,6 +101,26 @@ class DojoValidators {
return value;
}
});
readonly enonceValidator = this.toValidatorSchemaOptions({
bail : true,
errorMessage: 'Template doesn\'t exist or you don\'t have access to it',
options : (value, {
req,
location,
path
}) => {
return new Promise((resolve, reject) => {
const template = this.getParamValue(req, path);
if ( template ) {
GitlabManager.checkTemplateAccess(template, req).then((templateAccess) => {
templateAccess !== StatusCodes.OK ? reject() : resolve(true);
});
}
resolve(true);
});
}
});
}
......
......@@ -43,7 +43,7 @@ class EnonceRoutes implements RoutesManager {
members : {
trim : true,
notEmpty : true,
customSanitizer: DojoValidators.arraySanitizer
customSanitizer: DojoValidators.jsonSanitizer
},
template: {
trim : true,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment