Skip to content

Commit

Permalink
#1218: Improve Slovenian vat number validator, thanks to @Glavic
Browse files Browse the repository at this point in the history
  • Loading branch information
nghuuphuoc committed Dec 1, 2014
1 parent 108b152 commit 45f1cf9
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 22 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ __Improvements__
* [#1177](https://github.com/nghuuphuoc/bootstrapvalidator/issues/1177): Don't need to set the [different](http://bootstrapvalidator.com/validators/different/) validator for both fields
* [#1186](https://github.com/nghuuphuoc/bootstrapvalidator/issues/1186), [#1188](https://github.com/nghuuphuoc/bootstrapvalidator/pull/1188): Improve the [CPF](http://bootstrapvalidator.com/validators/id/) validator, thanks to [@igorescobar](https://github.com/igorescobar)
* [#1197](https://github.com/nghuuphuoc/bootstrapvalidator/pull/1197): Add sample data for [CPF](http://bootstrapvalidator.com/validators/id/) validator, thanks to [@dgmike](https://github.com/dgmike)
* [#1207](https://github.com/nghuuphuoc/bootstrapvalidator/pull/1207): Improve Spanish [phone](http://bootstrapvalidator.com/validators/zipCode/phone/) validator, thanks to [@ethernet-zero](https://github.com/ethernet-zero)
* [#1207](https://github.com/nghuuphuoc/bootstrapvalidator/pull/1207): Improve Spanish [phone](http://bootstrapvalidator.com/validators/phone/) validator, thanks to [@ethernet-zero](https://github.com/ethernet-zero)
* [#1218](https://github.com/nghuuphuoc/bootstrapvalidator/pull/1218): Improve Slovenian [vat number](http://bootstrapvalidator.com/validators/vat/) validator, thanks to [@Glavic](https://github.com/Glavic)

__Bug Fixes__
* [#1101](https://github.com/nghuuphuoc/bootstrapvalidator/issues/1101): The [cusip](http://bootstrapvalidator.com/validators/cusip/) validator doesn't work
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ I would like to give big thanks to the following contributors:
* [@filipac](https://github.com/filipac)
* [@Francismori7](https://github.com/Francismori7)
* [@gercheq](https://github.com/gercheq)
* [@Glavic](https://github.com/Glavic)
* [@grzesiek](https://github.com/grzesiek)
* [@henningda](https://github.com/henningda)
* [@i0](https://github.com/i0)
Expand Down
2 changes: 1 addition & 1 deletion dist/css/formValidation.min.css

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

13 changes: 8 additions & 5 deletions dist/js/formValidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* FormValidation (http://bootstrapvalidator.com)
* The best jQuery plugin to validate form fields. Support Bootstrap, Foundation, SemanticUI, UIKit frameworks
*
* @version v0.6.0-dev, built on 2014-12-01 5:44:51 PM
* @version v0.6.0-dev, built on 2014-12-01 10:35:56 PM
* @author https://twitter.com/nghuuphuoc
* @copyright (c) 2013 - 2014 Nguyen Huu Phuoc
* @license http://bootstrapvalidator.com/license/
Expand Down Expand Up @@ -8645,17 +8645,20 @@ if (typeof jQuery === 'undefined') {
* Examples:
* - Valid: SI50223054
* - Invalid: SI50223055
* - Invalid: SI09999990
*
* @param {String} value VAT number
* @returns {Boolean}
*/
_si: function(value) {
if (/^SI[0-9]{8}$/.test(value)) {
value = value.substr(2);
}
if (!/^[0-9]{8}$/.test(value)) {
// The Slovenian VAT numbers don't start with zero
var res = value.match(/^(SI)?([1-9][0-9]{7})$/);
if (!res) {
return false;
}
if (res[1]) {
value = value.substr(2);
}

var sum = 0,
weight = [8, 7, 6, 5, 4, 3, 2];
Expand Down
4 changes: 2 additions & 2 deletions dist/js/formValidation.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/js/framework/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
* FormValidation (http://bootstrapvalidator.com)
* The best jQuery plugin to validate form fields. Support Bootstrap, Foundation, SemanticUI, UIKit frameworks
*
* @version v0.6.0-dev, built on 2014-12-01 5:44:51 PM
* @version v0.6.0-dev, built on 2014-12-01 10:35:56 PM
* @author https://twitter.com/nghuuphuoc
* @copyright (c) 2013 - 2014 Nguyen Huu Phuoc
* @license http://bootstrapvalidator.com/license/
*/
/**
* This class supports Bootstrap (http://getbootstrap.com/)
* This class supports validating Bootstrap form (http://getbootstrap.com/)
*/
(function($) {
FormValidation.Framework.Bootstrap = function(element, options) {
Expand Down
2 changes: 1 addition & 1 deletion dist/js/framework/bootstrap.min.js

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

4 changes: 2 additions & 2 deletions dist/js/framework/foundation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
* FormValidation (http://bootstrapvalidator.com)
* The best jQuery plugin to validate form fields. Support Bootstrap, Foundation, SemanticUI, UIKit frameworks
*
* @version v0.6.0-dev, built on 2014-12-01 5:44:51 PM
* @version v0.6.0-dev, built on 2014-12-01 10:35:56 PM
* @author https://twitter.com/nghuuphuoc
* @copyright (c) 2013 - 2014 Nguyen Huu Phuoc
* @license http://bootstrapvalidator.com/license/
*/
/**
* This class supports validating Foundation framework (http://foundation.zurb.com/)
* This class supports validating Foundation form (http://foundation.zurb.com/)
*/
/* global Foundation: false */
(function($) {
Expand Down
2 changes: 1 addition & 1 deletion dist/js/framework/foundation.min.js

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

4 changes: 2 additions & 2 deletions dist/js/framework/semantic.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
* FormValidation (http://bootstrapvalidator.com)
* The best jQuery plugin to validate form fields. Support Bootstrap, Foundation, SemanticUI, UIKit frameworks
*
* @version v0.6.0-dev, built on 2014-12-01 5:44:51 PM
* @version v0.6.0-dev, built on 2014-12-01 10:35:56 PM
* @author https://twitter.com/nghuuphuoc
* @copyright (c) 2013 - 2014 Nguyen Huu Phuoc
* @license http://bootstrapvalidator.com/license/
*/
/**
* This class supports validating SemanticUI framework (http://semantic-ui.com/)
* This class supports validating SemanticUI form (http://semantic-ui.com/)
*/
(function($) {
FormValidation.Framework.Semantic = function(element, options) {
Expand Down
2 changes: 1 addition & 1 deletion dist/js/framework/semantic.min.js

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

4 changes: 2 additions & 2 deletions dist/js/framework/uikit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
* FormValidation (http://bootstrapvalidator.com)
* The best jQuery plugin to validate form fields. Support Bootstrap, Foundation, SemanticUI, UIKit frameworks
*
* @version v0.6.0-dev, built on 2014-12-01 5:44:51 PM
* @version v0.6.0-dev, built on 2014-12-01 10:35:56 PM
* @author https://twitter.com/nghuuphuoc
* @copyright (c) 2013 - 2014 Nguyen Huu Phuoc
* @license http://bootstrapvalidator.com/license/
*/
/**
* This class supports validating UIKit framework (http://getuikit.com/)
* This class supports validating UIKit form (http://getuikit.com/)
*/
(function($) {
FormValidation.Framework.UIKit = function(element, options) {
Expand Down
2 changes: 1 addition & 1 deletion dist/js/framework/uikit.min.js

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

1 change: 1 addition & 0 deletions src/js/validator/vat.js
Original file line number Diff line number Diff line change
Expand Up @@ -1333,6 +1333,7 @@
* @returns {Boolean}
*/
_si: function(value) {
// The Slovenian VAT numbers don't start with zero
var res = value.match(/^(SI)?([1-9][0-9]{7})$/);
if (!res) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion test/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8329,7 +8329,7 @@ describe('vat', function() {
}

// Invalid samples
var invalidSamples = ['SI50223055', '50223055'];
var invalidSamples = ['SI50223055', '50223055', 'SI09999990', '09999990'];
for (i in invalidSamples) {
this.fv.resetForm();
this.$vat.val(invalidSamples[i]);
Expand Down

0 comments on commit 45f1cf9

Please sign in to comment.