Skip to content

Commit

Permalink
v1.0.2
Browse files Browse the repository at this point in the history
Moved pattern match error to the end to make sure other errors are caught first
  • Loading branch information
cferdinandi committed Jun 8, 2017
1 parent a56f278 commit efb5fef
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 44 deletions.
24 changes: 12 additions & 12 deletions dist/js/validate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* validate v1.0.1: A lightweight form validation script that augments native HTML5 form validation elements and attributes.
* validate v1.0.2: A lightweight form validation script that augments native HTML5 form validation elements and attributes.
* (c) 2017 Chris Ferdinandi
* MIT License
* http://github.com/cferdinandi/validate
Expand Down Expand Up @@ -179,17 +179,6 @@
// If too long
if (validity.tooLong) return localSettings.messageTooLong.replace('{minLength}', field.getAttribute('maxLength')).replace('{length}', field.value.length);

// If pattern doesn't match
if (validity.patternMismatch) {

// If pattern info is included, return custom error
if (field.hasAttribute('title')) return field.getAttribute('title');

// Otherwise, generic error
return localSettings.messagePatternMismatch;

}

// If number input isn't a number
if (validity.badInput) return localSettings.messageBadInput;

Expand All @@ -202,6 +191,17 @@
// If a number field is below the min
if (validity.rangeUnderflow) return localSettings.messageRangeUnderflow.replace('{min}', field.getAttribute('min'));

// If pattern doesn't match
if (validity.patternMismatch) {

// If pattern info is included, return custom error
if (field.hasAttribute('title')) return field.getAttribute('title');

// Otherwise, generic error
return localSettings.messagePatternMismatch;

}

// If all else fails, return a generic catchall error
return localSettings.messageGeneric;

Expand Down
4 changes: 2 additions & 2 deletions dist/js/validate.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/js/validityState-polyfill.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* validate v1.0.1: A lightweight form validation script that augments native HTML5 form validation elements and attributes.
* validate v1.0.2: A lightweight form validation script that augments native HTML5 form validation elements and attributes.
* (c) 2017 Chris Ferdinandi
* MIT License
* http://github.com/cferdinandi/validate
Expand Down
2 changes: 1 addition & 1 deletion dist/js/validityState-polyfill.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions docs/dist/js/validate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* validate v1.0.1: A lightweight form validation script that augments native HTML5 form validation elements and attributes.
* validate v1.0.2: A lightweight form validation script that augments native HTML5 form validation elements and attributes.
* (c) 2017 Chris Ferdinandi
* MIT License
* http://github.com/cferdinandi/validate
Expand Down Expand Up @@ -179,17 +179,6 @@
// If too long
if (validity.tooLong) return localSettings.messageTooLong.replace('{minLength}', field.getAttribute('maxLength')).replace('{length}', field.value.length);

// If pattern doesn't match
if (validity.patternMismatch) {

// If pattern info is included, return custom error
if (field.hasAttribute('title')) return field.getAttribute('title');

// Otherwise, generic error
return localSettings.messagePatternMismatch;

}

// If number input isn't a number
if (validity.badInput) return localSettings.messageBadInput;

Expand All @@ -202,6 +191,17 @@
// If a number field is below the min
if (validity.rangeUnderflow) return localSettings.messageRangeUnderflow.replace('{min}', field.getAttribute('min'));

// If pattern doesn't match
if (validity.patternMismatch) {

// If pattern info is included, return custom error
if (field.hasAttribute('title')) return field.getAttribute('title');

// Otherwise, generic error
return localSettings.messagePatternMismatch;

}

// If all else fails, return a generic catchall error
return localSettings.messageGeneric;

Expand Down
Loading

0 comments on commit efb5fef

Please sign in to comment.