Skip to content

Commit fa007ad

Browse files
author
Bruno Besson
committed
glurp
1 parent 96d5ea0 commit fa007ad

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/config.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
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';
63

74
convict.addFormats({
85
baseUrl: {
96
// 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
107
coerce: (v: any) => v.toString(),
118
validate: (value: string) => {
12-
if (!isUrl(value, { require_tld: false, require_protocol: false })) {
9+
if (!validator.isURL(value, { require_tld: false, require_protocol: false })) {
1310
throw new Error('must be a URL');
1411
}
1512
if (!value.endsWith('/')) {
@@ -21,7 +18,7 @@ convict.addFormats({
2118
// 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
2219
coerce: (v: any) => v.toString(),
2320
validate: (value: string) => {
24-
if (!isUUID(value, 4)) {
21+
if (!validator.isUUID(value, 4)) {
2522
throw new Error('must be a UUID version 4');
2623
}
2724
},
@@ -30,7 +27,7 @@ convict.addFormats({
3027
// 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
3128
coerce: (v: any) => v.toString(),
3229
validate: (value: string) => {
33-
if (!value.trim().length || !isBase64(value)) {
30+
if (!value.trim().length || !validator.isBase64(value)) {
3431
throw new Error('must be a non-empty base64 string');
3532
}
3633
},
@@ -39,7 +36,7 @@ convict.addFormats({
3936
// 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
4037
coerce: (v: any) => v.toString(),
4138
validate: (value: string) => {
42-
if (!isStrongPassword(value)) {
39+
if (!validator.isStrongPassword(value)) {
4340
throw new Error('must be a strong password');
4441
}
4542
},

0 commit comments

Comments
 (0)