From 7bcc5976038745b361f845ca3af519759efe9dc6 Mon Sep 17 00:00:00 2001 From: Henrique Laki <138539381+henriquelakiap@users.noreply.github.com> Date: Fri, 12 Apr 2024 11:44:14 -0300 Subject: [PATCH] Sc 63647/submission of json objects to string fields (#171) * Add string validation and 'format is valid/invalid' operators to last_name and city --- lib/types/city.js | 2 ++ lib/types/last_name.js | 2 ++ test/city.test.js | 17 +++++++++++++++++ test/first-name.test.js | 13 +++++++++++++ test/last-name.test.js | 13 +++++++++++++ 5 files changed, 47 insertions(+) diff --git a/lib/types/city.js b/lib/types/city.js index 3f50654..6aeec0b 100644 --- a/lib/types/city.js +++ b/lib/types/city.js @@ -23,6 +23,8 @@ module.exports = { 'is not equal to', 'is blank', 'is not blank', + 'format is valid', + 'format is invalid', 'includes', 'does not include', 'is included in', diff --git a/lib/types/last_name.js b/lib/types/last_name.js index 3302508..7b06b60 100644 --- a/lib/types/last_name.js +++ b/lib/types/last_name.js @@ -23,6 +23,8 @@ module.exports = { 'is not equal to', 'is blank', 'is not blank', + 'format is valid', + 'format is invalid', 'matches pattern', 'does not match pattern' ], diff --git a/test/city.test.js b/test/city.test.js index d8a916d..7dbab32 100644 --- a/test/city.test.js +++ b/test/city.test.js @@ -22,4 +22,21 @@ describe('City', function () { assert.equal(parsed.raw, '[object Object]'); assert.isFalse(parsed.valid); }); + + it('should have the expected operators', function () { + assert(city.operators, [ + 'is equal to', + 'is not equal to', + 'is blank', + 'is not blank', + 'format is valid', + 'format is invalid', + 'includes', + 'does not include', + 'is included in', + 'is not included in', + 'matches pattern', + 'does not match pattern' + ]); + }); }); diff --git a/test/first-name.test.js b/test/first-name.test.js index 8cf4252..48fcd17 100644 --- a/test/first-name.test.js +++ b/test/first-name.test.js @@ -22,4 +22,17 @@ describe('First Name', function () { assert.equal(parsed.raw, '[object Object]'); assert.isFalse(parsed.valid); }); + + it('should have the expected operators', function () { + assert.deepEqual(firstName.operators, [ + 'is equal to', + 'is not equal to', + 'is blank', + 'is not blank', + 'format is valid', + 'format is invalid', + 'matches pattern', + 'does not match pattern' + ]); + }); }); diff --git a/test/last-name.test.js b/test/last-name.test.js index b58df5b..b8a49c4 100644 --- a/test/last-name.test.js +++ b/test/last-name.test.js @@ -22,4 +22,17 @@ describe('Last Name', function () { assert.equal(parsed.raw, '[object Object]'); assert.isFalse(parsed.valid); }); + + it('should have the expected operators', function () { + assert.deepEqual(lastName.operators, [ + 'is equal to', + 'is not equal to', + 'is blank', + 'is not blank', + 'format is valid', + 'format is invalid', + 'matches pattern', + 'does not match pattern' + ]); + }); });