Skip to content

Commit 9e05492

Browse files
fix: j tests
1 parent efce837 commit 9e05492

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

packages/nodejs-lib/src/validation/ajv/j.validations.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff 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 = [

0 commit comments

Comments
 (0)