File tree Expand file tree Collapse file tree
packages/express-cargo/tests/validator Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -120,6 +120,21 @@ describe('isHash decorator', () => {
120120 } )
121121 } )
122122
123+ describe ( 'crc32b' , ( ) => {
124+ const meta = classMeta . getFieldMetadata ( 'crc32bHash' )
125+ const rule = meta . getValidators ( ) ?. find ( v => v . type === 'isHash' )
126+
127+ it ( 'should pass for valid crc32b hash' , ( ) => {
128+ expect ( rule ! . validate ( '00000000' ) ) . toBeNull ( )
129+ expect ( rule ! . validate ( 'cbf43926' ) ) . toBeNull ( )
130+ } )
131+
132+ it ( 'should fail for invalid crc32b hash' , ( ) => {
133+ expect ( rule ! . validate ( '0000000' ) ) . toBeInstanceOf ( CargoFieldError )
134+ expect ( rule ! . validate ( 'cbf439260' ) ) . toBeInstanceOf ( CargoFieldError )
135+ } )
136+ } )
137+
123138 it ( 'should fail for non-string values' , ( ) => {
124139 const meta = classMeta . getFieldMetadata ( 'md5Hash' )
125140 const rule = meta . getValidators ( ) ?. find ( v => v . type === 'isHash' )
You can’t perform that action at this time.
0 commit comments