File tree Expand file tree Collapse file tree
packages/nodejs-lib/src/validation/ajv Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1418,6 +1418,23 @@ describe('string', () => {
14181418 } )
14191419 } )
14201420
1421+ describe ( 'cpf' , ( ) => {
1422+ const schema = j . string ( ) . cpf ( )
1423+
1424+ test ( 'should accept valid CPF in both formatted and unformatted forms' , ( ) => {
1425+ const [ errFormatted ] = schema . getValidationResult ( '529.982.247-25' )
1426+ expect ( errFormatted ) . toBeNull ( )
1427+
1428+ const [ errUnformatted ] = schema . getValidationResult ( '52998224725' )
1429+ expect ( errUnformatted ) . toBeNull ( )
1430+ } )
1431+
1432+ test ( 'should reject invalid CPF with correct error message' , ( ) => {
1433+ const [ err ] = schema . getValidationResult ( '52998224726' )
1434+ expect ( err ?. message ) . toContain ( 'is an invalid CPF number' )
1435+ } )
1436+ } )
1437+
14211438 describe ( 'uuid' , ( ) => {
14221439 test ( 'should accept valid data' , ( ) => {
14231440 const testCases = [
You can’t perform that action at this time.
0 commit comments