Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

Commit

Permalink
🗣 — 0.11.9 ⁰˙¹¹˙⁹ ˙⁹
Browse files Browse the repository at this point in the history
  • Loading branch information
1000hz committed Jan 6, 2017
1 parent 5d74c22 commit dfa97d6
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 45 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Changelog
=========
### 0.11.9
* Fixing another issue with `<select multiple/>` elements. (#463)
* No longer skipping a custom validator if its attribute has a falsy value. (#475)
* Fixing stale values being read for data-attributes.

### 0.11.8
* Properly updating the submit button state when you run `.validator(‘update’)`. (#461)
* Clearing errors on fields with `data-validate="false"` upon calling `.validator('update')`. (#387)
Expand Down
36 changes: 18 additions & 18 deletions dist/validator.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* Validator v0.11.8 for Bootstrap 3, by @1000hz
* Copyright 2016 Cina Saffary
* Validator v0.11.9 for Bootstrap 3, by @1000hz
* Copyright 2017 Cina Saffary
* Licensed under http://opensource.org/licenses/MIT
*
* https://github.com/1000hz/bootstrap-validator
Expand All @@ -15,7 +15,7 @@
function getValue($el) {
return $el.is('[type="checkbox"]') ? $el.prop('checked') :
$el.is('[type="radio"]') ? !!$('[name="' + $el.attr('name') + '"]:checked').length :
$el.is('select[multiple]') ? +$el.val() ? $el.val() : null :
$el.is('select[multiple]') ? ($el.val() || []).length :
$el.val()
}

Expand All @@ -35,7 +35,7 @@

this.$element.find('[data-match]').each(function () {
var $this = $(this)
var target = $this.data('match')
var target = $this.attr('data-match')

$(target).on('input.bs.validator', function (e) {
getValue($this) && $this.trigger('input.bs.validator')
Expand All @@ -50,7 +50,7 @@
this.$element.attr('novalidate', true) // disable automatic native validation
}

Validator.VERSION = '0.11.8'
Validator.VERSION = '0.11.9'

Validator.INPUT_SELECTOR = ':input:not([type="hidden"], [type="submit"], [type="reset"], button)'

Expand Down Expand Up @@ -80,11 +80,11 @@
}
},
'match': function ($el) {
var target = $el.data('match')
var target = $el.attr('data-match')
return $el.val() !== $(target).val() && Validator.DEFAULTS.errors.match
},
'minlength': function ($el) {
var minlength = $el.data('minlength')
var minlength = $el.attr('data-minlength')
return $el.val().length < minlength && Validator.DEFAULTS.errors.minlength
}
}
Expand Down Expand Up @@ -157,22 +157,22 @@
$el.data('bs.validator.deferred', deferred)

function getValidatorSpecificError(key) {
return $el.data(key + '-error')
return $el.attr('data-' + key + '-error')
}

function getValidityStateError() {
var validity = $el[0].validity
return validity.typeMismatch ? $el.data('type-error')
: validity.patternMismatch ? $el.data('pattern-error')
: validity.stepMismatch ? $el.data('step-error')
: validity.rangeOverflow ? $el.data('max-error')
: validity.rangeUnderflow ? $el.data('min-error')
: validity.valueMissing ? $el.data('required-error')
return validity.typeMismatch ? $el.attr('data-type-error')
: validity.patternMismatch ? $el.attr('data-pattern-error')
: validity.stepMismatch ? $el.attr('data-step-error')
: validity.rangeOverflow ? $el.attr('data-max-error')
: validity.rangeUnderflow ? $el.attr('data-min-error')
: validity.valueMissing ? $el.attr('data-required-error')
: null
}

function getGenericError() {
return $el.data('error')
return $el.attr('data-error')
}

function getErrorMessage(key) {
Expand All @@ -184,18 +184,18 @@
$.each(this.validators, $.proxy(function (key, validator) {
var error = null
if ((getValue($el) || $el.attr('required')) &&
($el.data(key) || key == 'native') &&
($el.attr('data-' + key) !== undefined || key == 'native') &&
(error = validator.call(this, $el))) {
error = getErrorMessage(key) || error
!~errors.indexOf(error) && errors.push(error)
}
}, this))

if (!errors.length && getValue($el) && $el.data('remote')) {
if (!errors.length && getValue($el) && $el.attr('data-remote')) {
this.defer($el, function () {
var data = {}
data[$el.attr('name')] = getValue($el)
$.get($el.data('remote'), data)
$.get($el.attr('data-remote'), data)
.fail(function (jqXHR, textStatus, error) { errors.push(getErrorMessage('remote') || error) })
.always(function () { deferred.resolve(errors)})
})
Expand Down
6 changes: 3 additions & 3 deletions dist/validator.min.js

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

Loading

0 comments on commit dfa97d6

Please sign in to comment.