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.
- checksums.yaml +4 -4
- data/lib/bootstrap_validator_rails/version.rb +1 -1
- data/vendor/assets/javascripts/bootstrapValidator.js +4677 -2
- data/vendor/assets/javascripts/bootstrapValidator.min.js +12 -0
- data/vendor/assets/stylesheets/bootstrapValidator.min.css +11 -0
- metadata +4 -48
- data/vendor/assets/javascripts/validator/base64.js +0 -25
- data/vendor/assets/javascripts/validator/between.js +0 -66
- data/vendor/assets/javascripts/validator/callback.js +0 -40
- data/vendor/assets/javascripts/validator/choice.js +0 -68
- data/vendor/assets/javascripts/validator/creditCard.js +0 -103
- data/vendor/assets/javascripts/validator/cusip.js +0 -55
- data/vendor/assets/javascripts/validator/cvv.js +0 -116
- data/vendor/assets/javascripts/validator/date.js +0 -118
- data/vendor/assets/javascripts/validator/different.js +0 -41
- data/vendor/assets/javascripts/validator/digits.js +0 -24
- data/vendor/assets/javascripts/validator/ean.js +0 -40
- data/vendor/assets/javascripts/validator/emailAddress.js +0 -31
- data/vendor/assets/javascripts/validator/file.js +0 -69
- data/vendor/assets/javascripts/validator/greaterThan.js +0 -61
- data/vendor/assets/javascripts/validator/grid.js +0 -37
- data/vendor/assets/javascripts/validator/hex.js +0 -25
- data/vendor/assets/javascripts/validator/hexColor.js +0 -28
- data/vendor/assets/javascripts/validator/iban.js +0 -246
- data/vendor/assets/javascripts/validator/id.js +0 -815
- data/vendor/assets/javascripts/validator/identical.js +0 -40
- data/vendor/assets/javascripts/validator/imei.js +0 -44
- data/vendor/assets/javascripts/validator/integer.js +0 -28
- data/vendor/assets/javascripts/validator/ip.js +0 -48
- data/vendor/assets/javascripts/validator/isbn.js +0 -86
- data/vendor/assets/javascripts/validator/isin.js +0 -59
- data/vendor/assets/javascripts/validator/ismn.js +0 -59
- data/vendor/assets/javascripts/validator/issn.js +0 -46
- data/vendor/assets/javascripts/validator/lessThan.js +0 -61
- data/vendor/assets/javascripts/validator/mac.js +0 -25
- data/vendor/assets/javascripts/validator/notEmpty.js +0 -32
- data/vendor/assets/javascripts/validator/numeric.js +0 -39
- data/vendor/assets/javascripts/validator/phone.js +0 -84
- data/vendor/assets/javascripts/validator/regexp.js +0 -42
- data/vendor/assets/javascripts/validator/remote.js +0 -70
- data/vendor/assets/javascripts/validator/rtn.js +0 -38
- data/vendor/assets/javascripts/validator/sedol.js +0 -40
- data/vendor/assets/javascripts/validator/siren.js +0 -28
- data/vendor/assets/javascripts/validator/siret.js +0 -38
- data/vendor/assets/javascripts/validator/step.js +0 -64
- data/vendor/assets/javascripts/validator/stringCase.js +0 -36
- data/vendor/assets/javascripts/validator/stringLength.js +0 -81
- data/vendor/assets/javascripts/validator/uri.js +0 -101
- data/vendor/assets/javascripts/validator/uuid.js +0 -46
- data/vendor/assets/javascripts/validator/vat.js +0 -1220
- data/vendor/assets/javascripts/validator/vin.js +0 -49
- data/vendor/assets/javascripts/validator/zipCode.js +0 -162
@@ -1,49 +0,0 @@
|
|
1
|
-
(function($) {
|
2
|
-
$.fn.bootstrapValidator.i18n.vin = $.extend($.fn.bootstrapValidator.i18n.vin || {}, {
|
3
|
-
'default': 'Please enter a valid VIN number'
|
4
|
-
});
|
5
|
-
|
6
|
-
$.fn.bootstrapValidator.validators.vin = {
|
7
|
-
/**
|
8
|
-
* Validate an US VIN (Vehicle Identification 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
|
-
// Don't accept I, O, Q characters
|
23
|
-
if (!/^[a-hj-npr-z0-9]{8}[0-9xX][a-hj-npr-z0-9]{8}$/i.test(value)) {
|
24
|
-
return false;
|
25
|
-
}
|
26
|
-
|
27
|
-
value = value.toUpperCase();
|
28
|
-
var chars = {
|
29
|
-
A: 1, B: 2, C: 3, D: 4, E: 5, F: 6, G: 7, H: 8,
|
30
|
-
J: 1, K: 2, L: 3, M: 4, N: 5, P: 7, R: 9,
|
31
|
-
S: 2, T: 3, U: 4, V: 5, W: 6, X: 7, Y: 8, Z: 9,
|
32
|
-
'1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '0': 0
|
33
|
-
},
|
34
|
-
weights = [8, 7, 6, 5, 4, 3, 2, 10, 0, 9, 8, 7, 6, 5, 4, 3, 2],
|
35
|
-
sum = 0,
|
36
|
-
length = value.length;
|
37
|
-
for (var i = 0; i < length; i++) {
|
38
|
-
sum += chars[value.charAt(i) + ''] * weights[i];
|
39
|
-
}
|
40
|
-
|
41
|
-
var reminder = sum % 11;
|
42
|
-
if (reminder === 10) {
|
43
|
-
reminder = 'X';
|
44
|
-
}
|
45
|
-
|
46
|
-
return (reminder + '') === value.charAt(8);
|
47
|
-
}
|
48
|
-
};
|
49
|
-
}(window.jQuery));
|
@@ -1,162 +0,0 @@
|
|
1
|
-
(function($) {
|
2
|
-
$.fn.bootstrapValidator.i18n.zipCode = $.extend($.fn.bootstrapValidator.i18n.zipCode || {}, {
|
3
|
-
'default': 'Please enter a valid zip code',
|
4
|
-
countryNotSupported: 'The country code %s is not supported',
|
5
|
-
country: 'Please enter a valid %s',
|
6
|
-
countries: {
|
7
|
-
'CA': 'Canadian postal code',
|
8
|
-
'DK': 'Danish postal code',
|
9
|
-
'GB': 'United Kingdom postal code',
|
10
|
-
'IT': 'Italian postal code',
|
11
|
-
'NL': 'Dutch postal code',
|
12
|
-
'SE': 'Swiss postal code',
|
13
|
-
'SG': 'Singapore postal code',
|
14
|
-
'US': 'US zip code'
|
15
|
-
}
|
16
|
-
});
|
17
|
-
|
18
|
-
$.fn.bootstrapValidator.validators.zipCode = {
|
19
|
-
html5Attributes: {
|
20
|
-
message: 'message',
|
21
|
-
country: 'country'
|
22
|
-
},
|
23
|
-
|
24
|
-
COUNTRY_CODES: ['CA', 'DK', 'GB', 'IT', 'NL', 'SE', 'SG', 'US'],
|
25
|
-
|
26
|
-
/**
|
27
|
-
* Return true if and only if the input value is a valid country zip code
|
28
|
-
*
|
29
|
-
* @param {BootstrapValidator} validator The validator plugin instance
|
30
|
-
* @param {jQuery} $field Field element
|
31
|
-
* @param {Object} options Consist of key:
|
32
|
-
* - message: The invalid message
|
33
|
-
* - country: The country
|
34
|
-
*
|
35
|
-
* The country can be defined by:
|
36
|
-
* - An ISO 3166 country code
|
37
|
-
* Currently it supports the following countries:
|
38
|
-
* - US (United States)
|
39
|
-
* - CA (Canada)
|
40
|
-
* - DK (Denmark)
|
41
|
-
* - GB (United Kingdom)
|
42
|
-
* - IT (Italy)
|
43
|
-
* - NL (Netherlands)
|
44
|
-
* - SE (Sweden)
|
45
|
-
* - SG (Singapore)
|
46
|
-
*
|
47
|
-
* - Name of field which its value defines the country code
|
48
|
-
* - Name of callback function that returns the country code
|
49
|
-
* - A callback function that returns the country code
|
50
|
-
*
|
51
|
-
* callback: function(value, validator, $field) {
|
52
|
-
* // value is the value of field
|
53
|
-
* // validator is the BootstrapValidator instance
|
54
|
-
* // $field is jQuery element representing the field
|
55
|
-
* }
|
56
|
-
*
|
57
|
-
* @returns {Boolean|Object}
|
58
|
-
*/
|
59
|
-
validate: function(validator, $field, options) {
|
60
|
-
var value = $field.val();
|
61
|
-
if (value === '' || !options.country) {
|
62
|
-
return true;
|
63
|
-
}
|
64
|
-
|
65
|
-
var country = options.country;
|
66
|
-
if (typeof country !== 'string' || $.inArray(country, this.COUNTRY_CODES) === -1) {
|
67
|
-
// Try to determine the country
|
68
|
-
country = validator.getDynamicOption($field, country);
|
69
|
-
}
|
70
|
-
|
71
|
-
if (!country || $.inArray(country.toUpperCase(), this.COUNTRY_CODES) === -1) {
|
72
|
-
return { valid: false, message: $.fn.bootstrapValidator.helpers.format($.fn.bootstrapValidator.i18n.zipCode.countryNotSupported, country) };
|
73
|
-
}
|
74
|
-
|
75
|
-
var isValid = false;
|
76
|
-
country = country.toUpperCase();
|
77
|
-
switch (country) {
|
78
|
-
case 'CA':
|
79
|
-
isValid = /^(?:A|B|C|E|G|H|J|K|L|M|N|P|R|S|T|V|X|Y){1}[0-9]{1}(?:A|B|C|E|G|H|J|K|L|M|N|P|R|S|T|V|W|X|Y|Z){1}\s?[0-9]{1}(?:A|B|C|E|G|H|J|K|L|M|N|P|R|S|T|V|W|X|Y|Z){1}[0-9]{1}$/i.test(value);
|
80
|
-
break;
|
81
|
-
|
82
|
-
case 'DK':
|
83
|
-
isValid = /^(DK(-|\s)?)?\d{4}$/i.test(value);
|
84
|
-
break;
|
85
|
-
|
86
|
-
case 'GB':
|
87
|
-
isValid = this._gb(value);
|
88
|
-
break;
|
89
|
-
|
90
|
-
// http://en.wikipedia.org/wiki/List_of_postal_codes_in_Italy
|
91
|
-
case 'IT':
|
92
|
-
isValid = /^(I-|IT-)?\d{5}$/i.test(value);
|
93
|
-
break;
|
94
|
-
|
95
|
-
// http://en.wikipedia.org/wiki/Postal_codes_in_the_Netherlands
|
96
|
-
case 'NL':
|
97
|
-
isValid = /^[1-9][0-9]{3} ?(?!sa|sd|ss)[a-z]{2}$/i.test(value);
|
98
|
-
break;
|
99
|
-
|
100
|
-
case 'SE':
|
101
|
-
isValid = /^(S-)?\d{3}\s?\d{2}$/i.test(value);
|
102
|
-
break;
|
103
|
-
|
104
|
-
case 'SG':
|
105
|
-
isValid = /^([0][1-9]|[1-6][0-9]|[7]([0-3]|[5-9])|[8][0-2])(\d{4})$/i.test(value);
|
106
|
-
break;
|
107
|
-
|
108
|
-
case 'US':
|
109
|
-
/* falls through */
|
110
|
-
default:
|
111
|
-
isValid = /^\d{4,5}([\-]?\d{4})?$/.test(value);
|
112
|
-
break;
|
113
|
-
}
|
114
|
-
|
115
|
-
return {
|
116
|
-
valid: isValid,
|
117
|
-
message: $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.zipCode.country, $.fn.bootstrapValidator.i18n.zipCode.countries[country])
|
118
|
-
};
|
119
|
-
},
|
120
|
-
|
121
|
-
/**
|
122
|
-
* Validate United Kingdom postcode
|
123
|
-
* Examples:
|
124
|
-
* - Standard: EC1A 1BB, W1A 1HQ, M1 1AA, B33 8TH, CR2 6XH, DN55 1PT
|
125
|
-
* - Special cases:
|
126
|
-
* AI-2640, ASCN 1ZZ, GIR 0AA
|
127
|
-
*
|
128
|
-
* @see http://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom
|
129
|
-
* @param {String} value The postcode
|
130
|
-
* @returns {Boolean}
|
131
|
-
*/
|
132
|
-
_gb: function(value) {
|
133
|
-
var firstChar = '[ABCDEFGHIJKLMNOPRSTUWYZ]', // Does not accept QVX
|
134
|
-
secondChar = '[ABCDEFGHKLMNOPQRSTUVWXY]', // Does not accept IJZ
|
135
|
-
thirdChar = '[ABCDEFGHJKPMNRSTUVWXY]',
|
136
|
-
fourthChar = '[ABEHMNPRVWXY]',
|
137
|
-
fifthChar = '[ABDEFGHJLNPQRSTUWXYZ]',
|
138
|
-
regexps = [
|
139
|
-
// AN NAA, ANN NAA, AAN NAA, AANN NAA format
|
140
|
-
new RegExp('^(' + firstChar + '{1}' + secondChar + '?[0-9]{1,2})(\\s*)([0-9]{1}' + fifthChar + '{2})$', 'i'),
|
141
|
-
// ANA NAA
|
142
|
-
new RegExp('^(' + firstChar + '{1}[0-9]{1}' + thirdChar + '{1})(\\s*)([0-9]{1}' + fifthChar + '{2})$', 'i'),
|
143
|
-
// AANA NAA
|
144
|
-
new RegExp('^(' + firstChar + '{1}' + secondChar + '{1}?[0-9]{1}' + fourthChar + '{1})(\\s*)([0-9]{1}' + fifthChar + '{2})$', 'i'),
|
145
|
-
|
146
|
-
new RegExp('^(BF1)(\\s*)([0-6]{1}[ABDEFGHJLNPQRST]{1}[ABDEFGHJLNPQRSTUWZYZ]{1})$', 'i'), // BFPO postcodes
|
147
|
-
/^(GIR)(\s*)(0AA)$/i, // Special postcode GIR 0AA
|
148
|
-
/^(BFPO)(\s*)([0-9]{1,4})$/i, // Standard BFPO numbers
|
149
|
-
/^(BFPO)(\s*)(c\/o\s*[0-9]{1,3})$/i, // c/o BFPO numbers
|
150
|
-
/^([A-Z]{4})(\s*)(1ZZ)$/i, // Overseas Territories
|
151
|
-
/^(AI-2640)$/i // Anguilla
|
152
|
-
];
|
153
|
-
for (var i = 0; i < regexps.length; i++) {
|
154
|
-
if (regexps[i].test(value)) {
|
155
|
-
return true;
|
156
|
-
}
|
157
|
-
}
|
158
|
-
|
159
|
-
return false;
|
160
|
-
}
|
161
|
-
};
|
162
|
-
}(window.jQuery));
|