-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add options object to allow finer-grained validation #48
base: master
Are you sure you want to change the base?
Conversation
function validate(issn, options) { | ||
var opts = options ? options : { strict: false }; | ||
|
||
var issnPattern = opts.strict === true | ||
? '^(\\d{4})-(\\d{3})([\\dX])$' // hyphen is required | ||
: '^(\\d{4})-?(\\d{3})([\\dX])$'; // hyphen is optional | ||
var isIssn = new RegExp(issnPattern); | ||
|
||
var matches = text(issn).match(isIssn); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the validation logic to support stricter validation.
"jasmine-node": "3.0.0", | ||
"lodash": "^4.17.21" | ||
}, | ||
"dependencies": { | ||
"get-stdin": "7.0.0", | ||
"minimist": "^1.2.6" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Swapped from minimist
to yargs
only 'cos there was a bug in testing the CLI with the new stricter validation option.
@@ -1,6 +1,6 @@ | |||
{ | |||
"name": "issn", | |||
"version": "1.0.6", | |||
"version": "2.0.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Major version bump because the function signature is changing: the options
argument is optional but it's still a change.
Closes #47