bootstrap_validator_rails 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- 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,116 +0,0 @@
|
|
1
|
-
(function($) {
|
2
|
-
$.fn.bootstrapValidator.i18n.cvv = $.extend($.fn.bootstrapValidator.i18n.cvv || {}, {
|
3
|
-
'default': 'Please enter a valid CVV number'
|
4
|
-
});
|
5
|
-
|
6
|
-
$.fn.bootstrapValidator.validators.cvv = {
|
7
|
-
html5Attributes: {
|
8
|
-
message: 'message',
|
9
|
-
ccfield: 'creditCardField'
|
10
|
-
},
|
11
|
-
|
12
|
-
/**
|
13
|
-
* Return true if the input value is a valid CVV number.
|
14
|
-
*
|
15
|
-
* @param {BootstrapValidator} validator The validator plugin instance
|
16
|
-
* @param {jQuery} $field Field element
|
17
|
-
* @param {Object} options Can consist of the following keys:
|
18
|
-
* - creditCardField: The credit card number field. It can be null
|
19
|
-
* - message: The invalid message
|
20
|
-
* @returns {Boolean}
|
21
|
-
*/
|
22
|
-
validate: function(validator, $field, options) {
|
23
|
-
var value = $field.val();
|
24
|
-
if (value === '') {
|
25
|
-
return true;
|
26
|
-
}
|
27
|
-
|
28
|
-
if (!/^[0-9]{3,4}$/.test(value)) {
|
29
|
-
return false;
|
30
|
-
}
|
31
|
-
|
32
|
-
if (!options.creditCardField) {
|
33
|
-
return true;
|
34
|
-
}
|
35
|
-
|
36
|
-
// Get the credit card number
|
37
|
-
var creditCard = validator.getFieldElements(options.creditCardField).val();
|
38
|
-
if (creditCard === '') {
|
39
|
-
return true;
|
40
|
-
}
|
41
|
-
|
42
|
-
creditCard = creditCard.replace(/\D/g, '');
|
43
|
-
|
44
|
-
// Supported credit card types
|
45
|
-
var cards = {
|
46
|
-
AMERICAN_EXPRESS: {
|
47
|
-
length: [15],
|
48
|
-
prefix: ['34', '37']
|
49
|
-
},
|
50
|
-
DINERS_CLUB: {
|
51
|
-
length: [14],
|
52
|
-
prefix: ['300', '301', '302', '303', '304', '305', '36']
|
53
|
-
},
|
54
|
-
DINERS_CLUB_US: {
|
55
|
-
length: [16],
|
56
|
-
prefix: ['54', '55']
|
57
|
-
},
|
58
|
-
DISCOVER: {
|
59
|
-
length: [16],
|
60
|
-
prefix: ['6011', '622126', '622127', '622128', '622129', '62213',
|
61
|
-
'62214', '62215', '62216', '62217', '62218', '62219',
|
62
|
-
'6222', '6223', '6224', '6225', '6226', '6227', '6228',
|
63
|
-
'62290', '62291', '622920', '622921', '622922', '622923',
|
64
|
-
'622924', '622925', '644', '645', '646', '647', '648',
|
65
|
-
'649', '65']
|
66
|
-
},
|
67
|
-
JCB: {
|
68
|
-
length: [16],
|
69
|
-
prefix: ['3528', '3529', '353', '354', '355', '356', '357', '358']
|
70
|
-
},
|
71
|
-
LASER: {
|
72
|
-
length: [16, 17, 18, 19],
|
73
|
-
prefix: ['6304', '6706', '6771', '6709']
|
74
|
-
},
|
75
|
-
MAESTRO: {
|
76
|
-
length: [12, 13, 14, 15, 16, 17, 18, 19],
|
77
|
-
prefix: ['5018', '5020', '5038', '6304', '6759', '6761', '6762', '6763', '6764', '6765', '6766']
|
78
|
-
},
|
79
|
-
MASTERCARD: {
|
80
|
-
length: [16],
|
81
|
-
prefix: ['51', '52', '53', '54', '55']
|
82
|
-
},
|
83
|
-
SOLO: {
|
84
|
-
length: [16, 18, 19],
|
85
|
-
prefix: ['6334', '6767']
|
86
|
-
},
|
87
|
-
UNIONPAY: {
|
88
|
-
length: [16, 17, 18, 19],
|
89
|
-
prefix: ['622126', '622127', '622128', '622129', '62213', '62214',
|
90
|
-
'62215', '62216', '62217', '62218', '62219', '6222', '6223',
|
91
|
-
'6224', '6225', '6226', '6227', '6228', '62290', '62291',
|
92
|
-
'622920', '622921', '622922', '622923', '622924', '622925']
|
93
|
-
},
|
94
|
-
VISA: {
|
95
|
-
length: [16],
|
96
|
-
prefix: ['4']
|
97
|
-
}
|
98
|
-
};
|
99
|
-
var type, i, creditCardType = null;
|
100
|
-
for (type in cards) {
|
101
|
-
for (i in cards[type].prefix) {
|
102
|
-
if (creditCard.substr(0, cards[type].prefix[i].length) === cards[type].prefix[i] // Check the prefix
|
103
|
-
&& $.inArray(creditCard.length, cards[type].length) !== -1) // and length
|
104
|
-
{
|
105
|
-
creditCardType = type;
|
106
|
-
break;
|
107
|
-
}
|
108
|
-
}
|
109
|
-
}
|
110
|
-
|
111
|
-
return (creditCardType === null)
|
112
|
-
? false
|
113
|
-
: (('AMERICAN_EXPRESS' === creditCardType) ? (value.length === 4) : (value.length === 3));
|
114
|
-
}
|
115
|
-
};
|
116
|
-
}(window.jQuery));
|
@@ -1,118 +0,0 @@
|
|
1
|
-
(function($) {
|
2
|
-
$.fn.bootstrapValidator.i18n.date = $.extend($.fn.bootstrapValidator.i18n.date || {}, {
|
3
|
-
'default': 'Please enter a valid date'
|
4
|
-
});
|
5
|
-
|
6
|
-
$.fn.bootstrapValidator.validators.date = {
|
7
|
-
html5Attributes: {
|
8
|
-
message: 'message',
|
9
|
-
format: 'format',
|
10
|
-
separator: 'separator'
|
11
|
-
},
|
12
|
-
|
13
|
-
/**
|
14
|
-
* Return true if the input value is valid date
|
15
|
-
*
|
16
|
-
* @param {BootstrapValidator} validator The validator plugin instance
|
17
|
-
* @param {jQuery} $field Field element
|
18
|
-
* @param {Object} options Can consist of the following keys:
|
19
|
-
* - message: The invalid message
|
20
|
-
* - separator: Use to separate the date, month, and year.
|
21
|
-
* By default, it is /
|
22
|
-
* - format: The date format. Default is MM/DD/YYYY
|
23
|
-
* The format can be:
|
24
|
-
*
|
25
|
-
* i) date: Consist of DD, MM, YYYY parts which are separated by the separator option
|
26
|
-
* ii) date and time:
|
27
|
-
* The time can consist of h, m, s parts which are separated by :
|
28
|
-
* ii) date, time and A (indicating AM or PM)
|
29
|
-
* @returns {Boolean}
|
30
|
-
*/
|
31
|
-
validate: function(validator, $field, options) {
|
32
|
-
var value = $field.val();
|
33
|
-
if (value === '') {
|
34
|
-
return true;
|
35
|
-
}
|
36
|
-
|
37
|
-
options.format = options.format || 'MM/DD/YYYY';
|
38
|
-
|
39
|
-
var formats = options.format.split(' '),
|
40
|
-
dateFormat = formats[0],
|
41
|
-
timeFormat = (formats.length > 1) ? formats[1] : null,
|
42
|
-
amOrPm = (formats.length > 2) ? formats[2] : null,
|
43
|
-
sections = value.split(' '),
|
44
|
-
date = sections[0],
|
45
|
-
time = (sections.length > 1) ? sections[1] : null;
|
46
|
-
|
47
|
-
if (formats.length !== sections.length) {
|
48
|
-
return false;
|
49
|
-
}
|
50
|
-
|
51
|
-
// Determine the separator
|
52
|
-
var separator = options.separator;
|
53
|
-
if (!separator) {
|
54
|
-
separator = (date.indexOf('/') !== -1) ? '/' : ((date.indexOf('-') !== -1) ? '-' : null);
|
55
|
-
}
|
56
|
-
if (separator === null || date.indexOf(separator) === -1) {
|
57
|
-
return false;
|
58
|
-
}
|
59
|
-
|
60
|
-
// Determine the date
|
61
|
-
date = date.split(separator);
|
62
|
-
dateFormat = dateFormat.split(separator);
|
63
|
-
if (date.length !== dateFormat.length) {
|
64
|
-
return false;
|
65
|
-
}
|
66
|
-
|
67
|
-
var year = date[$.inArray('YYYY', dateFormat)],
|
68
|
-
month = date[$.inArray('MM', dateFormat)],
|
69
|
-
day = date[$.inArray('DD', dateFormat)];
|
70
|
-
|
71
|
-
if (!year || !month || !day) {
|
72
|
-
return false;
|
73
|
-
}
|
74
|
-
|
75
|
-
// Determine the time
|
76
|
-
var minutes = null, hours = null, seconds = null;
|
77
|
-
if (timeFormat) {
|
78
|
-
timeFormat = timeFormat.split(':');
|
79
|
-
time = time.split(':');
|
80
|
-
|
81
|
-
if (timeFormat.length !== time.length) {
|
82
|
-
return false;
|
83
|
-
}
|
84
|
-
|
85
|
-
hours = time.length > 0 ? time[0] : null;
|
86
|
-
minutes = time.length > 1 ? time[1] : null;
|
87
|
-
seconds = time.length > 2 ? time[2] : null;
|
88
|
-
|
89
|
-
// Validate seconds
|
90
|
-
if (seconds) {
|
91
|
-
seconds = parseInt(seconds, 10);
|
92
|
-
if (isNaN(seconds) || seconds < 0 || seconds > 60) {
|
93
|
-
return false;
|
94
|
-
}
|
95
|
-
}
|
96
|
-
|
97
|
-
// Validate hours
|
98
|
-
if (hours) {
|
99
|
-
hours = parseInt(hours, 10);
|
100
|
-
if (isNaN(hours) || hours < 0 || hours >= 24 || (amOrPm && hours > 12)) {
|
101
|
-
return false;
|
102
|
-
}
|
103
|
-
}
|
104
|
-
|
105
|
-
// Validate minutes
|
106
|
-
if (minutes) {
|
107
|
-
minutes = parseInt(minutes, 10);
|
108
|
-
if (isNaN(minutes) || minutes < 0 || minutes > 59) {
|
109
|
-
return false;
|
110
|
-
}
|
111
|
-
}
|
112
|
-
}
|
113
|
-
|
114
|
-
// Validate day, month, and year
|
115
|
-
return $.fn.bootstrapValidator.helpers.date(year, month, day);
|
116
|
-
}
|
117
|
-
};
|
118
|
-
}(window.jQuery));
|
@@ -1,41 +0,0 @@
|
|
1
|
-
(function($) {
|
2
|
-
$.fn.bootstrapValidator.i18n.different = $.extend($.fn.bootstrapValidator.i18n.different || {}, {
|
3
|
-
'default': 'Please enter a different value'
|
4
|
-
});
|
5
|
-
|
6
|
-
$.fn.bootstrapValidator.validators.different = {
|
7
|
-
html5Attributes: {
|
8
|
-
message: 'message',
|
9
|
-
field: 'field'
|
10
|
-
},
|
11
|
-
|
12
|
-
/**
|
13
|
-
* Return true if the input value is different with given field's value
|
14
|
-
*
|
15
|
-
* @param {BootstrapValidator} validator The validator plugin instance
|
16
|
-
* @param {jQuery} $field Field element
|
17
|
-
* @param {Object} options Consists of the following key:
|
18
|
-
* - field: The name of field that will be used to compare with current one
|
19
|
-
* - message: The invalid message
|
20
|
-
* @returns {Boolean}
|
21
|
-
*/
|
22
|
-
validate: function(validator, $field, options) {
|
23
|
-
var value = $field.val();
|
24
|
-
if (value === '') {
|
25
|
-
return true;
|
26
|
-
}
|
27
|
-
|
28
|
-
var compareWith = validator.getFieldElements(options.field);
|
29
|
-
if (compareWith === null) {
|
30
|
-
return true;
|
31
|
-
}
|
32
|
-
|
33
|
-
if (value !== compareWith.val()) {
|
34
|
-
validator.updateStatus(options.field, validator.STATUS_VALID, 'different');
|
35
|
-
return true;
|
36
|
-
} else {
|
37
|
-
return false;
|
38
|
-
}
|
39
|
-
}
|
40
|
-
};
|
41
|
-
}(window.jQuery));
|
@@ -1,24 +0,0 @@
|
|
1
|
-
(function($) {
|
2
|
-
$.fn.bootstrapValidator.i18n.digits = $.extend($.fn.bootstrapValidator.i18n.digits || {}, {
|
3
|
-
'default': 'Please enter only digits'
|
4
|
-
});
|
5
|
-
|
6
|
-
$.fn.bootstrapValidator.validators.digits = {
|
7
|
-
/**
|
8
|
-
* Return true if the input value contains digits only
|
9
|
-
*
|
10
|
-
* @param {BootstrapValidator} validator Validate plugin instance
|
11
|
-
* @param {jQuery} $field Field element
|
12
|
-
* @param {Object} [options]
|
13
|
-
* @returns {Boolean}
|
14
|
-
*/
|
15
|
-
validate: function(validator, $field, options) {
|
16
|
-
var value = $field.val();
|
17
|
-
if (value === '') {
|
18
|
-
return true;
|
19
|
-
}
|
20
|
-
|
21
|
-
return /^\d+$/.test(value);
|
22
|
-
}
|
23
|
-
};
|
24
|
-
}(window.jQuery));
|
@@ -1,40 +0,0 @@
|
|
1
|
-
(function($) {
|
2
|
-
$.fn.bootstrapValidator.i18n.ean = $.extend($.fn.bootstrapValidator.i18n.ean || {}, {
|
3
|
-
'default': 'Please enter a valid EAN number'
|
4
|
-
});
|
5
|
-
|
6
|
-
$.fn.bootstrapValidator.validators.ean = {
|
7
|
-
/**
|
8
|
-
* Validate EAN (International Article Number)
|
9
|
-
* Examples:
|
10
|
-
* - Valid: 73513537, 9780471117094, 4006381333931
|
11
|
-
* - Invalid: 73513536
|
12
|
-
*
|
13
|
-
* @see http://en.wikipedia.org/wiki/European_Article_Number
|
14
|
-
* @param {BootstrapValidator} validator The validator plugin instance
|
15
|
-
* @param {jQuery} $field Field element
|
16
|
-
* @param {Object} options Can consist of the following keys:
|
17
|
-
* - message: The invalid message
|
18
|
-
* @returns {Boolean}
|
19
|
-
*/
|
20
|
-
validate: function(validator, $field, options) {
|
21
|
-
var value = $field.val();
|
22
|
-
if (value === '') {
|
23
|
-
return true;
|
24
|
-
}
|
25
|
-
|
26
|
-
if (!/^(\d{8}|\d{12}|\d{13})$/.test(value)) {
|
27
|
-
return false;
|
28
|
-
}
|
29
|
-
|
30
|
-
var length = value.length,
|
31
|
-
sum = 0,
|
32
|
-
weight = (length === 8) ? [3, 1] : [1, 3];
|
33
|
-
for (var i = 0; i < length - 1; i++) {
|
34
|
-
sum += parseInt(value.charAt(i), 10) * weight[i % 2];
|
35
|
-
}
|
36
|
-
sum = (10 - sum % 10) % 10;
|
37
|
-
return (sum + '' === value.charAt(length - 1));
|
38
|
-
}
|
39
|
-
};
|
40
|
-
}(window.jQuery));
|
@@ -1,31 +0,0 @@
|
|
1
|
-
(function($) {
|
2
|
-
$.fn.bootstrapValidator.i18n.emailAddress = $.extend($.fn.bootstrapValidator.i18n.emailAddress || {}, {
|
3
|
-
'default': 'Please enter a valid email address'
|
4
|
-
});
|
5
|
-
|
6
|
-
$.fn.bootstrapValidator.validators.emailAddress = {
|
7
|
-
enableByHtml5: function($field) {
|
8
|
-
return ('email' === $field.attr('type'));
|
9
|
-
},
|
10
|
-
|
11
|
-
/**
|
12
|
-
* Return true if and only if the input value is a valid email address
|
13
|
-
*
|
14
|
-
* @param {BootstrapValidator} validator Validate plugin instance
|
15
|
-
* @param {jQuery} $field Field element
|
16
|
-
* @param {Object} [options]
|
17
|
-
* @returns {Boolean}
|
18
|
-
*/
|
19
|
-
validate: function(validator, $field, options) {
|
20
|
-
var value = $field.val();
|
21
|
-
if (value === '') {
|
22
|
-
return true;
|
23
|
-
}
|
24
|
-
|
25
|
-
// Email address regular expression
|
26
|
-
// http://stackoverflow.com/questions/46155/validate-email-address-in-javascript
|
27
|
-
var emailRegExp = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
28
|
-
return emailRegExp.test(value);
|
29
|
-
}
|
30
|
-
};
|
31
|
-
}(window.jQuery));
|
@@ -1,69 +0,0 @@
|
|
1
|
-
(function($) {
|
2
|
-
$.fn.bootstrapValidator.i18n.file = $.extend($.fn.bootstrapValidator.i18n.file || {}, {
|
3
|
-
'default': 'Please choose a valid file'
|
4
|
-
});
|
5
|
-
|
6
|
-
$.fn.bootstrapValidator.validators.file = {
|
7
|
-
html5Attributes: {
|
8
|
-
extension: 'extension',
|
9
|
-
maxsize: 'maxSize',
|
10
|
-
message: 'message',
|
11
|
-
type: 'type'
|
12
|
-
},
|
13
|
-
|
14
|
-
/**
|
15
|
-
* Validate upload file. Use HTML 5 API if the browser supports
|
16
|
-
*
|
17
|
-
* @param {BootstrapValidator} validator The validator plugin instance
|
18
|
-
* @param {jQuery} $field Field element
|
19
|
-
* @param {Object} options Can consist of the following keys:
|
20
|
-
* - extension: The allowed extensions, separated by a comma
|
21
|
-
* - maxSize: The maximum size in bytes
|
22
|
-
* - message: The invalid message
|
23
|
-
* - type: The allowed MIME type, separated by a comma
|
24
|
-
* @returns {Boolean}
|
25
|
-
*/
|
26
|
-
validate: function(validator, $field, options) {
|
27
|
-
var value = $field.val();
|
28
|
-
if (value === '') {
|
29
|
-
return true;
|
30
|
-
}
|
31
|
-
|
32
|
-
var ext,
|
33
|
-
extensions = options.extension ? options.extension.toLowerCase().split(',') : null,
|
34
|
-
types = options.type ? options.type.toLowerCase().split(',') : null,
|
35
|
-
html5 = (window.File && window.FileList && window.FileReader);
|
36
|
-
|
37
|
-
if (html5) {
|
38
|
-
// Get FileList instance
|
39
|
-
var files = $field.get(0).files,
|
40
|
-
total = files.length;
|
41
|
-
for (var i = 0; i < total; i++) {
|
42
|
-
// Check file size
|
43
|
-
if (options.maxSize && files[i].size > parseInt(options.maxSize, 10)) {
|
44
|
-
return false;
|
45
|
-
}
|
46
|
-
|
47
|
-
// Check file extension
|
48
|
-
ext = files[i].name.substr(files[i].name.lastIndexOf('.') + 1);
|
49
|
-
if (extensions && $.inArray(ext.toLowerCase(), extensions) === -1) {
|
50
|
-
return false;
|
51
|
-
}
|
52
|
-
|
53
|
-
// Check file type
|
54
|
-
if (types && $.inArray(files[i].type.toLowerCase(), types) === -1) {
|
55
|
-
return false;
|
56
|
-
}
|
57
|
-
}
|
58
|
-
} else {
|
59
|
-
// Check file extension
|
60
|
-
ext = value.substr(value.lastIndexOf('.') + 1);
|
61
|
-
if (extensions && $.inArray(ext.toLowerCase(), extensions) === -1) {
|
62
|
-
return false;
|
63
|
-
}
|
64
|
-
}
|
65
|
-
|
66
|
-
return true;
|
67
|
-
}
|
68
|
-
};
|
69
|
-
}(window.jQuery));
|