Skip to content

Commit deadc7c

Browse files
committed
chore: add test for @IsStrongPassword()
1 parent deada3f commit deadc7c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

__tests__/defaultConverters.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ import _get from 'lodash.get'
55
import { validationMetadatasToSchemas } from '../src'
66

77
class Post {}
8+
89
class Comment {}
910

1011
enum PostType {
1112
Public,
1213
Private,
1314
}
15+
1416
enum Role {
1517
Anonymous = 'anonymous',
1618
User = 'user',
@@ -137,6 +139,9 @@ class User {
137139
@validator.ArrayMaxSize(10)
138140
arrayMaxSize: any[]
139141
@validator.ArrayUnique() arrayUnique: any[]
142+
143+
@validator.IsStrongPassword()
144+
password!: string
140145
}
141146

142147
const metadata = _get(
@@ -326,6 +331,11 @@ describe('defaultConverters', () => {
326331
arrayMinSize: { type: 'array', items: {}, minItems: 1 },
327332
arrayMaxSize: { type: 'array', items: {}, maxItems: 10 },
328333
arrayUnique: { type: 'array', items: {}, uniqueItems: true },
334+
password: {
335+
type: 'string',
336+
pattern:
337+
'^(?=.{8})(?=.*(?:[^a-z]*[a-z]){1})(?=.*(?:[^A-Z]*[A-Z]){1})(?=.*(?:[^0-9]*[0-9]){1})(?=.*(?:[^-#!$@£%^&*()_+|~=`{}\\[\\]:";\'<>?,.\\/ ]*[-#!$@£%^&*()_+|~=`{}\\[\\]:";\'<>?,.\\/ ]){1}).*$',
338+
},
329339
},
330340
required: expect.any(Array),
331341
type: 'object',

0 commit comments

Comments
 (0)