bootstrap_validator_rails 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bootstrap_validator_rails/version.rb +1 -1
  3. data/vendor/assets/javascripts/bootstrapValidator.js +4677 -2
  4. data/vendor/assets/javascripts/bootstrapValidator.min.js +12 -0
  5. data/vendor/assets/stylesheets/bootstrapValidator.min.css +11 -0
  6. metadata +4 -48
  7. data/vendor/assets/javascripts/validator/base64.js +0 -25
  8. data/vendor/assets/javascripts/validator/between.js +0 -66
  9. data/vendor/assets/javascripts/validator/callback.js +0 -40
  10. data/vendor/assets/javascripts/validator/choice.js +0 -68
  11. data/vendor/assets/javascripts/validator/creditCard.js +0 -103
  12. data/vendor/assets/javascripts/validator/cusip.js +0 -55
  13. data/vendor/assets/javascripts/validator/cvv.js +0 -116
  14. data/vendor/assets/javascripts/validator/date.js +0 -118
  15. data/vendor/assets/javascripts/validator/different.js +0 -41
  16. data/vendor/assets/javascripts/validator/digits.js +0 -24
  17. data/vendor/assets/javascripts/validator/ean.js +0 -40
  18. data/vendor/assets/javascripts/validator/emailAddress.js +0 -31
  19. data/vendor/assets/javascripts/validator/file.js +0 -69
  20. data/vendor/assets/javascripts/validator/greaterThan.js +0 -61
  21. data/vendor/assets/javascripts/validator/grid.js +0 -37
  22. data/vendor/assets/javascripts/validator/hex.js +0 -25
  23. data/vendor/assets/javascripts/validator/hexColor.js +0 -28
  24. data/vendor/assets/javascripts/validator/iban.js +0 -246
  25. data/vendor/assets/javascripts/validator/id.js +0 -815
  26. data/vendor/assets/javascripts/validator/identical.js +0 -40
  27. data/vendor/assets/javascripts/validator/imei.js +0 -44
  28. data/vendor/assets/javascripts/validator/integer.js +0 -28
  29. data/vendor/assets/javascripts/validator/ip.js +0 -48
  30. data/vendor/assets/javascripts/validator/isbn.js +0 -86
  31. data/vendor/assets/javascripts/validator/isin.js +0 -59
  32. data/vendor/assets/javascripts/validator/ismn.js +0 -59
  33. data/vendor/assets/javascripts/validator/issn.js +0 -46
  34. data/vendor/assets/javascripts/validator/lessThan.js +0 -61
  35. data/vendor/assets/javascripts/validator/mac.js +0 -25
  36. data/vendor/assets/javascripts/validator/notEmpty.js +0 -32
  37. data/vendor/assets/javascripts/validator/numeric.js +0 -39
  38. data/vendor/assets/javascripts/validator/phone.js +0 -84
  39. data/vendor/assets/javascripts/validator/regexp.js +0 -42
  40. data/vendor/assets/javascripts/validator/remote.js +0 -70
  41. data/vendor/assets/javascripts/validator/rtn.js +0 -38
  42. data/vendor/assets/javascripts/validator/sedol.js +0 -40
  43. data/vendor/assets/javascripts/validator/siren.js +0 -28
  44. data/vendor/assets/javascripts/validator/siret.js +0 -38
  45. data/vendor/assets/javascripts/validator/step.js +0 -64
  46. data/vendor/assets/javascripts/validator/stringCase.js +0 -36
  47. data/vendor/assets/javascripts/validator/stringLength.js +0 -81
  48. data/vendor/assets/javascripts/validator/uri.js +0 -101
  49. data/vendor/assets/javascripts/validator/uuid.js +0 -46
  50. data/vendor/assets/javascripts/validator/vat.js +0 -1220
  51. data/vendor/assets/javascripts/validator/vin.js +0 -49
  52. data/vendor/assets/javascripts/validator/zipCode.js +0 -162
@@ -1,25 +0,0 @@
1
- (function($) {
2
- $.fn.bootstrapValidator.i18n.mac = $.extend($.fn.bootstrapValidator.i18n.mac || {}, {
3
- 'default': 'Please enter a valid MAC address'
4
- });
5
-
6
- $.fn.bootstrapValidator.validators.mac = {
7
- /**
8
- * Return true if the input value is a MAC address.
9
- *
10
- * @param {BootstrapValidator} validator The validator plugin instance
11
- * @param {jQuery} $field Field element
12
- * @param {Object} options Can consist of the following keys:
13
- * - message: The invalid message
14
- * @returns {Boolean}
15
- */
16
- validate: function(validator, $field, options) {
17
- var value = $field.val();
18
- if (value === '') {
19
- return true;
20
- }
21
-
22
- return /^([0-9A-F]{2}[:-]){5}([0-9A-F]{2})$/.test(value);
23
- }
24
- };
25
- }(window.jQuery));
@@ -1,32 +0,0 @@
1
- (function($) {
2
- $.fn.bootstrapValidator.i18n.notEmpty = $.extend($.fn.bootstrapValidator.i18n.notEmpty || {}, {
3
- 'default': 'Please enter a value'
4
- });
5
-
6
- $.fn.bootstrapValidator.validators.notEmpty = {
7
- enableByHtml5: function($field) {
8
- var required = $field.attr('required') + '';
9
- return ('required' === required || 'true' === required);
10
- },
11
-
12
- /**
13
- * Check if input value is empty or not
14
- *
15
- * @param {BootstrapValidator} validator The validator plugin instance
16
- * @param {jQuery} $field Field element
17
- * @param {Object} options
18
- * @returns {Boolean}
19
- */
20
- validate: function(validator, $field, options) {
21
- var type = $field.attr('type');
22
- if ('radio' === type || 'checkbox' === type) {
23
- return validator
24
- .getFieldElements($field.attr('data-bv-field'))
25
- .filter(':checked')
26
- .length > 0;
27
- }
28
-
29
- return $.trim($field.val()) !== '';
30
- }
31
- };
32
- }(window.jQuery));
@@ -1,39 +0,0 @@
1
- (function($) {
2
- $.fn.bootstrapValidator.i18n.numeric = $.extend($.fn.bootstrapValidator.i18n.numeric || {}, {
3
- 'default': 'Please enter a valid float number'
4
- });
5
-
6
- $.fn.bootstrapValidator.validators.numeric = {
7
- html5Attributes: {
8
- message: 'message',
9
- separator: 'separator'
10
- },
11
-
12
- enableByHtml5: function($field) {
13
- return ('number' === $field.attr('type')) && ($field.attr('step') !== undefined) && ($field.attr('step') % 1 !== 0);
14
- },
15
-
16
- /**
17
- * Validate decimal number
18
- *
19
- * @param {BootstrapValidator} validator The validator plugin instance
20
- * @param {jQuery} $field Field element
21
- * @param {Object} options Consist of key:
22
- * - message: The invalid message
23
- * - separator: The decimal separator. Can be "." (default), ","
24
- * @returns {Boolean}
25
- */
26
- validate: function(validator, $field, options) {
27
- var value = $field.val();
28
- if (value === '') {
29
- return true;
30
- }
31
- var separator = options.separator || '.';
32
- if (separator !== '.') {
33
- value = value.replace(separator, '.');
34
- }
35
-
36
- return !isNaN(parseFloat(value)) && isFinite(value);
37
- }
38
- };
39
- }(window.jQuery));
@@ -1,84 +0,0 @@
1
- (function($) {
2
- $.fn.bootstrapValidator.i18n.phone = $.extend($.fn.bootstrapValidator.i18n.phone || {}, {
3
- 'default': 'Please enter a valid phone number',
4
- countryNotSupported: 'The country code %s is not supported',
5
- country: 'Please enter a valid phone number in %s',
6
- countries: {
7
- GB: 'United Kingdom',
8
- US: 'USA'
9
- }
10
- });
11
-
12
- $.fn.bootstrapValidator.validators.phone = {
13
- html5Attributes: {
14
- message: 'message',
15
- country: 'country'
16
- },
17
-
18
- // The supported countries
19
- COUNTRY_CODES: ['GB', 'US'],
20
-
21
- /**
22
- * Return true if the input value contains a valid phone number for the country
23
- * selected in the options
24
- *
25
- * @param {BootstrapValidator} validator Validate plugin instance
26
- * @param {jQuery} $field Field element
27
- * @param {Object} options Consist of key:
28
- * - message: The invalid message
29
- * - country: The ISO-3166 country code. It can be
30
- * - A country code
31
- * - Name of field which its value defines the country code
32
- * - Name of callback function that returns the country code
33
- * - A callback function that returns the country code
34
- *
35
- * Currently it only supports United State (US) or United Kingdom (GB) countries
36
- * @returns {Boolean|Object}
37
- */
38
- validate: function(validator, $field, options) {
39
- var value = $field.val();
40
- if (value === '') {
41
- return true;
42
- }
43
-
44
- var country = options.country;
45
- if (typeof country !== 'string' || $.inArray(country, this.COUNTRY_CODES) === -1) {
46
- // Try to determine the country
47
- country = validator.getDynamicOption($field, country);
48
- }
49
-
50
- if (!country || $.inArray(country.toUpperCase(), this.COUNTRY_CODES) === -1) {
51
- return {
52
- valid: false,
53
- message: $.fn.bootstrapValidator.helpers.format($.fn.bootstrapValidator.i18n.phone.countryNotSupported, country)
54
- };
55
- }
56
-
57
- var isValid = true;
58
- switch (country.toUpperCase()) {
59
- case 'GB':
60
- // http://aa-asterisk.org.uk/index.php/Regular_Expressions_for_Validating_and_Formatting_GB_Telephone_Numbers#Match_GB_telephone_number_in_any_format
61
- // Test: http://regexr.com/38uhv
62
- value = $.trim(value);
63
- isValid = (/^\(?(?:(?:0(?:0|11)\)?[\s-]?\(?|\+)44\)?[\s-]?\(?(?:0\)?[\s-]?\(?)?|0)(?:\d{2}\)?[\s-]?\d{4}[\s-]?\d{4}|\d{3}\)?[\s-]?\d{3}[\s-]?\d{3,4}|\d{4}\)?[\s-]?(?:\d{5}|\d{3}[\s-]?\d{3})|\d{5}\)?[\s-]?\d{4,5}|8(?:00[\s-]?11[\s-]?11|45[\s-]?46[\s-]?4\d))(?:(?:[\s-]?(?:x|ext\.?\s?|\#)\d+)?)$/).test(value);
64
- break;
65
-
66
- case 'US':
67
- /* falls through */
68
- default:
69
- // Make sure US phone numbers have 10 digits
70
- // May start with 1, +1, or 1-; should discard
71
- // Area code may be delimited with (), & sections may be delimited with . or -
72
- // Test: http://regexr.com/38mqi
73
- value = value.replace(/\D/g, '');
74
- isValid = (/^(?:(1\-?)|(\+1 ?))?\(?(\d{3})[\)\-\.]?(\d{3})[\-\.]?(\d{4})$/).test(value) && (value.length === 10);
75
- break;
76
- }
77
-
78
- return {
79
- valid: isValid,
80
- message: $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.phone.country, $.fn.bootstrapValidator.i18n.phone.countries[country])
81
- };
82
- }
83
- };
84
- }(window.jQuery));
@@ -1,42 +0,0 @@
1
- (function($) {
2
- $.fn.bootstrapValidator.i18n.regexp = $.extend($.fn.bootstrapValidator.i18n.regexp || {}, {
3
- 'default': 'Please enter a value matching the pattern'
4
- });
5
-
6
- $.fn.bootstrapValidator.validators.regexp = {
7
- html5Attributes: {
8
- message: 'message',
9
- regexp: 'regexp'
10
- },
11
-
12
- enableByHtml5: function($field) {
13
- var pattern = $field.attr('pattern');
14
- if (pattern) {
15
- return {
16
- regexp: pattern
17
- };
18
- }
19
-
20
- return false;
21
- },
22
-
23
- /**
24
- * Check if the element value matches given regular expression
25
- *
26
- * @param {BootstrapValidator} validator The validator plugin instance
27
- * @param {jQuery} $field Field element
28
- * @param {Object} options Consists of the following key:
29
- * - regexp: The regular expression you need to check
30
- * @returns {Boolean}
31
- */
32
- validate: function(validator, $field, options) {
33
- var value = $field.val();
34
- if (value === '') {
35
- return true;
36
- }
37
-
38
- var regexp = ('string' === typeof options.regexp) ? new RegExp(options.regexp) : options.regexp;
39
- return regexp.test(value);
40
- }
41
- };
42
- }(window.jQuery));
@@ -1,70 +0,0 @@
1
- (function($) {
2
- $.fn.bootstrapValidator.i18n.remote = $.extend($.fn.bootstrapValidator.i18n.remote || {}, {
3
- 'default': 'Please enter a valid value'
4
- });
5
-
6
- $.fn.bootstrapValidator.validators.remote = {
7
- html5Attributes: {
8
- message: 'message',
9
- url: 'url',
10
- name: 'name'
11
- },
12
-
13
- /**
14
- * Request a remote server to check the input value
15
- *
16
- * @param {BootstrapValidator} validator Plugin instance
17
- * @param {jQuery} $field Field element
18
- * @param {Object} options Can consist of the following keys:
19
- * - url {String|Function}
20
- * - type {String} [optional] Can be GET or POST (default)
21
- * - data {Object|Function} [optional]: By default, it will take the value
22
- * {
23
- * <fieldName>: <fieldValue>
24
- * }
25
- * - name {String} [optional]: Override the field name for the request.
26
- * - message: The invalid message
27
- * @returns {Boolean|Deferred}
28
- */
29
- validate: function(validator, $field, options) {
30
- var value = $field.val();
31
- if (value === '') {
32
- return true;
33
- }
34
-
35
- var name = $field.attr('data-bv-field'),
36
- data = options.data || {},
37
- url = options.url,
38
- type = options.type || 'POST';
39
-
40
- // Support dynamic data
41
- if ('function' === typeof data) {
42
- data = data.call(this, validator);
43
- }
44
-
45
- // Support dynamic url
46
- if ('function' === typeof url) {
47
- url = url.call(this, validator);
48
- }
49
-
50
- data[options.name || name] = value;
51
-
52
- var dfd = new $.Deferred();
53
- var xhr = $.ajax({
54
- type: type,
55
- url: url,
56
- dataType: 'json',
57
- data: data
58
- });
59
- xhr.then(function(response) {
60
- dfd.resolve($field, 'remote', response.valid === true || response.valid === 'true', response.message ? response.message : null);
61
- });
62
-
63
- dfd.fail(function() {
64
- xhr.abort();
65
- });
66
-
67
- return dfd;
68
- }
69
- };
70
- }(window.jQuery));
@@ -1,38 +0,0 @@
1
- (function($) {
2
- $.fn.bootstrapValidator.i18n.rtn = $.extend($.fn.bootstrapValidator.i18n.rtn || {}, {
3
- 'default': 'Please enter a valid RTN number'
4
- });
5
-
6
- $.fn.bootstrapValidator.validators.rtn = {
7
- /**
8
- * Validate a RTN (Routing transit number)
9
- * Examples:
10
- * - Valid: 021200025, 789456124
11
- *
12
- * @see http://en.wikipedia.org/wiki/Routing_transit_number
13
- * @param {BootstrapValidator} validator The validator plugin instance
14
- * @param {jQuery} $field Field element
15
- * @param {Object} options Can consist of the following keys:
16
- * - message: The invalid message
17
- * @returns {Boolean}
18
- */
19
- validate: function(validator, $field, options) {
20
- var value = $field.val();
21
- if (value === '') {
22
- return true;
23
- }
24
-
25
- if (!/^\d{9}$/.test(value)) {
26
- return false;
27
- }
28
-
29
- var sum = 0;
30
- for (var i = 0; i < value.length; i += 3) {
31
- sum += parseInt(value.charAt(i), 10) * 3
32
- + parseInt(value.charAt(i + 1), 10) * 7
33
- + parseInt(value.charAt(i + 2), 10);
34
- }
35
- return (sum !== 0 && sum % 10 === 0);
36
- }
37
- };
38
- }(window.jQuery));
@@ -1,40 +0,0 @@
1
- (function($) {
2
- $.fn.bootstrapValidator.i18n.sedol = $.extend($.fn.bootstrapValidator.i18n.sedol || {}, {
3
- 'default': 'Please enter a valid SEDOL number'
4
- });
5
-
6
- $.fn.bootstrapValidator.validators.sedol = {
7
- /**
8
- * Validate a SEDOL (Stock Exchange Daily Official List)
9
- * Examples:
10
- * - Valid: 0263494, B0WNLY7
11
- *
12
- * @see http://en.wikipedia.org/wiki/SEDOL
13
- * @param {BootstrapValidator} validator The validator plugin instance
14
- * @param {jQuery} $field Field element
15
- * @param {Object} options Can consist of the following keys:
16
- * - message: The invalid message
17
- * @returns {Boolean}
18
- */
19
- validate: function(validator, $field, options) {
20
- var value = $field.val();
21
- if (value === '') {
22
- return true;
23
- }
24
-
25
- value = value.toUpperCase();
26
- if (!/^[0-9A-Z]{7}$/.test(value)) {
27
- return false;
28
- }
29
-
30
- var sum = 0,
31
- weight = [1, 3, 1, 7, 3, 9, 1],
32
- length = value.length;
33
- for (var i = 0; i < length - 1; i++) {
34
- sum += weight[i] * parseInt(value.charAt(i), 36);
35
- }
36
- sum = (10 - sum % 10) % 10;
37
- return sum + '' === value.charAt(length - 1);
38
- }
39
- };
40
- }(window.jQuery));
@@ -1,28 +0,0 @@
1
- (function($) {
2
- $.fn.bootstrapValidator.i18n.siren = $.extend($.fn.bootstrapValidator.i18n.siren || {}, {
3
- 'default': 'Please enter a valid SIREN number'
4
- });
5
-
6
- $.fn.bootstrapValidator.validators.siren = {
7
- /**
8
- * Check if a string is a siren number
9
- *
10
- * @param {BootstrapValidator} validator The validator plugin instance
11
- * @param {jQuery} $field Field element
12
- * @param {Object} options Consist of key:
13
- * - message: The invalid message
14
- * @returns {Boolean}
15
- */
16
- validate: function(validator, $field, options) {
17
- var value = $field.val();
18
- if (value === '') {
19
- return true;
20
- }
21
-
22
- if (!/^\d{9}$/.test(value)) {
23
- return false;
24
- }
25
- return $.fn.bootstrapValidator.helpers.luhn(value);
26
- }
27
- };
28
- }(window.jQuery));
@@ -1,38 +0,0 @@
1
- (function($) {
2
- $.fn.bootstrapValidator.i18n.siret = $.extend($.fn.bootstrapValidator.i18n.siret || {}, {
3
- 'default': 'Please enter a valid SIRET number'
4
- });
5
-
6
- $.fn.bootstrapValidator.validators.siret = {
7
- /**
8
- * Check if a string is a siret number
9
- *
10
- * @param {BootstrapValidator} validator The validator plugin instance
11
- * @param {jQuery} $field Field element
12
- * @param {Object} options Consist of key:
13
- * - message: The invalid message
14
- * @returns {Boolean}
15
- */
16
- validate: function(validator, $field, options) {
17
- var value = $field.val();
18
- if (value === '') {
19
- return true;
20
- }
21
-
22
- var sum = 0,
23
- length = value.length,
24
- tmp;
25
- for (var i = 0; i < length; i++) {
26
- tmp = parseInt(value.charAt(i), 10);
27
- if ((i % 2) === 0) {
28
- tmp = tmp * 2;
29
- if (tmp > 9) {
30
- tmp -= 9;
31
- }
32
- }
33
- sum += tmp;
34
- }
35
- return (sum % 10 === 0);
36
- }
37
- };
38
- }(window.jQuery));