-
Notifications
You must be signed in to change notification settings - Fork 0
/
pl.js
70 lines (65 loc) · 1.98 KB
/
pl.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
Backbone-Forms validators PL 1.0.1
Copyright (c) 2016 Tomasz Jakub Rup
https://github.com/tomi77/backbone-forms-validators
Released under the MIT license
*/
(function(root, factory) {
/*
istanbul ignore next
*/
switch (false) {
case !(typeof define === 'function' && define.amd):
define(['underscore', 'backbone-forms', 'backbone-forms-validators'], factory);
break;
case typeof exports !== 'object':
factory(require('underscore'), require('backbone-forms'), require('backbone-forms-validators'));
break;
default:
factory(root._, root.Backbone.Form);
}
})(this, function(_, Form) {
Form.validators.errMessages.nip = 'Invalid NIP';
Form.validators.nip = function(options) {
options = _.extend({
type: 'nip',
message: Form.validators.errMessages.nip
}, options, {
lengths: 10,
weights: [6, 5, 7, 2, 3, 4, 5, 6, 7],
modulo_values: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0],
excepts: '0000000000'
});
return Form.validators.table_weights(options);
};
Form.validators.errMessages.pesel = 'Invalid Pesel';
Form.validators.pesel = function(options) {
options = _.extend({
type: 'pesel',
message: Form.validators.errMessages.pesel
}, options, {
lengths: 11,
weights: [9, 7, 3, 1, 9, 7, 3, 1, 9, 7],
modulo_values: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
excepts: '00000000000'
});
return Form.validators.table_weights(options);
};
Form.validators.errMessages.regon = 'Invalid REGON';
Form.validators.regon = function(options) {
options = _.extend({
type: 'regon',
message: Form.validators.errMessages.regon
}, options, {
lengths: [7, 9, 14],
weights: {
7: [2, 3, 4, 5, 6, 7],
9: [8, 9, 2, 3, 4, 5, 6, 7],
14: [2, 4, 8, 5, 0, 9, 7, 3, 6, 1, 2, 4, 8]
},
modulo_values: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0],
excepts: '000000000'
});
return Form.validators.table_weights(options);
};
});