Skip to content

Commit

Permalink
refactor(zip): replace default with US regex
Browse files Browse the repository at this point in the history
  • Loading branch information
psvet committed Mar 29, 2018
1 parent 1c0d433 commit aa8e54b
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/typeStrategies/zip.js
@@ -1,16 +1,10 @@
const zip = {
_regex: {
default: /^(?:[A-Z0-9]+([- ]?[A-Z0-9]+)*)?$/,
us: /^([0-9]{5})(?:[-\s]*([0-9]{4}))?$/,
default: /^([0-9]{5})(?:[-\s]*([0-9]{4}))?$/,
ca: /^([A-Z][0-9][A-Z])\s*([0-9][A-Z][0-9])$/
},
default: context => {
if (context.value === null || context.value && !context.value.toString().match(zip._regex.default)) {
context.fail('Value must be a valid zip code')
}
},
us: context => {
if (context.value === null || context.value && !context.value.toString().match(zip._regex.us)) {
context.fail('Value must be a valid US zip code')
}
},
Expand Down

0 comments on commit aa8e54b

Please sign in to comment.