Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DojoBackendAPI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dojo Project (HES-SO)
Projects
Backend
DojoBackendAPI
Commits
7d29c79d
Commit
7d29c79d
authored
2 years ago
by
michael.minelli
Browse files
Options
Downloads
Patches
Plain Diff
DojoValidator => Remove unused vars and validators
parent
419956e3
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
ExpressAPI/src/helpers/DojoValidators.ts
+3
-33
3 additions, 33 deletions
ExpressAPI/src/helpers/DojoValidators.ts
with
3 additions
and
33 deletions
ExpressAPI/src/helpers/DojoValidators.ts
+
3
−
33
View file @
7d29c79d
import
ApiRequest
from
'
../
model
s/ApiRequest
'
;
import
ApiRequest
from
'
../
type
s/ApiRequest
'
;
import
Config
from
'
../config/Config
'
;
import
{
StatusCodes
}
from
'
http-status-codes
'
;
import
{
CustomValidator
,
ErrorMessage
,
FieldMessageFactory
,
Meta
}
from
'
express-validator/src/base
'
;
...
...
@@ -36,11 +36,7 @@ class DojoValidators {
}
readonly
nullSanitizer
=
this
.
toValidatorSchemaOptions
({
options
:
(
value
,
{
req
,
location
,
path
})
=>
{
options
:
(
value
)
=>
{
try
{
return
value
==
'
null
'
||
value
==
'
undefined
'
||
value
==
''
?
null
:
value
;
}
catch
(
e
)
{
...
...
@@ -50,11 +46,7 @@ class DojoValidators {
});
readonly
jsonSanitizer
=
this
.
toValidatorSchemaOptions
({
options
:
(
value
,
{
req
,
location
,
path
})
=>
{
options
:
(
value
)
=>
{
try
{
return
JSON
.
parse
(
value
);
}
catch
(
e
)
{
...
...
@@ -68,7 +60,6 @@ class DojoValidators {
errorMessage
:
'
Template doesn
\'
t exist or you don
\'
t have access to it
'
,
options
:
(
value
,
{
req
,
location
,
path
})
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
...
...
@@ -86,7 +77,6 @@ class DojoValidators {
readonly
templateUrlSanitizer
=
this
.
toValidatorSchemaOptions
({
options
:
(
value
,
{
req
,
location
,
path
})
=>
{
try
{
...
...
@@ -101,26 +91,6 @@ 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
);
});
}
});
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment