1
1
import convict from 'convict' ;
2
- import isBase64 from 'validator/es/lib/isBase64' ;
3
- import isStrongPassword from 'validator/es/lib/isStrongPassword' ;
4
- import isUrl from 'validator/es/lib/isURL' ;
5
- import isUUID from 'validator/es/lib/isUUID' ;
2
+ import validator from 'validator' ;
6
3
7
4
convict . addFormats ( {
8
5
baseUrl : {
9
6
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
10
7
coerce : ( v : any ) => v . toString ( ) ,
11
8
validate : ( value : string ) => {
12
- if ( ! isUrl ( value , { require_tld : false , require_protocol : false } ) ) {
9
+ if ( ! validator . isURL ( value , { require_tld : false , require_protocol : false } ) ) {
13
10
throw new Error ( 'must be a URL' ) ;
14
11
}
15
12
if ( ! value . endsWith ( '/' ) ) {
@@ -21,7 +18,7 @@ convict.addFormats({
21
18
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
22
19
coerce : ( v : any ) => v . toString ( ) ,
23
20
validate : ( value : string ) => {
24
- if ( ! isUUID ( value , 4 ) ) {
21
+ if ( ! validator . isUUID ( value , 4 ) ) {
25
22
throw new Error ( 'must be a UUID version 4' ) ;
26
23
}
27
24
} ,
@@ -30,7 +27,7 @@ convict.addFormats({
30
27
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
31
28
coerce : ( v : any ) => v . toString ( ) ,
32
29
validate : ( value : string ) => {
33
- if ( ! value . trim ( ) . length || ! isBase64 ( value ) ) {
30
+ if ( ! value . trim ( ) . length || ! validator . isBase64 ( value ) ) {
34
31
throw new Error ( 'must be a non-empty base64 string' ) ;
35
32
}
36
33
} ,
@@ -39,7 +36,7 @@ convict.addFormats({
39
36
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
40
37
coerce : ( v : any ) => v . toString ( ) ,
41
38
validate : ( value : string ) => {
42
- if ( ! isStrongPassword ( value ) ) {
39
+ if ( ! validator . isStrongPassword ( value ) ) {
43
40
throw new Error ( 'must be a strong password' ) ;
44
41
}
45
42
} ,
0 commit comments