ende 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/component.json +2 -2
- data/components/indefinido/indemma/master/component.json +27 -17
- data/components/indefinido/indemma/master/lib/record/associable.js +74 -75
- data/components/indefinido/indemma/master/lib/record/dirtyable.js +40 -0
- data/components/indefinido/indemma/master/lib/record/queryable.js +2 -2
- data/components/indefinido/indemma/master/lib/record/resource.js +1 -1
- data/components/indefinido/indemma/master/lib/record/rest.js +7 -2
- data/components/indefinido/indemma/master/lib/record/restfulable.js +37 -10
- data/components/indefinido/indemma/master/lib/record/scopable.js +20 -47
- data/components/indefinido/indemma/master/lib/record/storable.js +11 -0
- data/components/indefinido/indemma/master/lib/record/validatable.js +195 -1068
- data/components/indefinido/indemma/master/lib/record.js +1 -1
- data/components/indefinido/indemma/master/vendor/stampit.js +568 -242
- data/components/indefinido/observable/es6-modules/component.json +39 -0
- data/components/indefinido/{indemma/master/components/indefinido-observable → observable/es6-modules}/lib/adapters/rivets.js +3 -1
- data/components/indefinido/observable/es6-modules/lib/legacy/notifierable.js +145 -0
- data/components/indefinido/observable/es6-modules/lib/legacy/schedulerable.js +114 -0
- data/components/indefinido/observable/es6-modules/lib/lookup.js +38 -0
- data/components/indefinido/observable/es6-modules/lib/observable/keypath_observer.js +38 -0
- data/components/indefinido/observable/es6-modules/lib/observable/observation.js +45 -0
- data/components/indefinido/observable/es6-modules/lib/observable/selection.js +57 -0
- data/components/indefinido/observable/es6-modules/lib/observable/self_observer.js +38 -0
- data/components/indefinido/observable/es6-modules/lib/observable.js +90 -0
- data/components/indefinido/observable/es6-modules/lib/platform.js +12 -0
- data/components/indefinido/observable/es6-modules/vendor/observe-js/observe.js +1631 -0
- data/components/indefinido/{indemma/master/components/indefinido-observable → observable/es6-modules}/vendor/shims/accessors.js +85 -10
- data/lib/assets/javascripts/aura/extensions/rivets.js.coffee +1 -1
- data/lib/ende/version.rb +1 -1
- data/vendor/assets/components/ende_build.js +18379 -26828
- metadata +20 -128
- data/components/indefinido/indemma/master/.gitignore +0 -17
- data/components/indefinido/indemma/master/.ruby-gemset +0 -1
- data/components/indefinido/indemma/master/.ruby-version +0 -1
- data/components/indefinido/indemma/master/Gemfile +0 -13
- data/components/indefinido/indemma/master/Guardfile +0 -39
- data/components/indefinido/indemma/master/History.md +0 -0
- data/components/indefinido/indemma/master/Readme.md +0 -447
- data/components/indefinido/indemma/master/build/build.js +0 -26288
- data/components/indefinido/indemma/master/build/development.js +0 -22200
- data/components/indefinido/indemma/master/build/release.js +0 -22139
- data/components/indefinido/indemma/master/build/test.js +0 -22200
- data/components/indefinido/indemma/master/components/chaijs-assertion-error/component.json +0 -18
- data/components/indefinido/indemma/master/components/chaijs-assertion-error/index.js +0 -110
- data/components/indefinido/indemma/master/components/chaijs-chai/component.json +0 -47
- data/components/indefinido/indemma/master/components/chaijs-chai/index.js +0 -1
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/assertion.js +0 -130
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/core/assertions.js +0 -1270
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/interface/assert.js +0 -1080
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/interface/expect.js +0 -12
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/interface/should.js +0 -76
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/addChainableMethod.js +0 -94
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/addMethod.js +0 -37
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/addProperty.js +0 -40
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/eql.js +0 -129
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/flag.js +0 -32
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/getActual.js +0 -19
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/getEnumerableProperties.js +0 -25
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/getMessage.js +0 -49
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/getName.js +0 -20
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/getPathValue.js +0 -102
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/getProperties.js +0 -35
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/index.js +0 -108
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/inspect.js +0 -320
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/objDisplay.js +0 -48
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/overwriteMethod.js +0 -51
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/overwriteProperty.js +0 -54
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/test.js +0 -26
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/transferFlags.js +0 -44
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/type.js +0 -45
- data/components/indefinido/indemma/master/components/chaijs-chai/lib/chai.js +0 -80
- data/components/indefinido/indemma/master/components/component-bind/component.json +0 -14
- data/components/indefinido/indemma/master/components/component-bind/index.js +0 -24
- data/components/indefinido/indemma/master/components/component-jquery/component.json +0 -14
- data/components/indefinido/indemma/master/components/component-jquery/index.js +0 -9601
- data/components/indefinido/indemma/master/components/component-type/component.json +0 -18
- data/components/indefinido/indemma/master/components/component-type/index.js +0 -32
- data/components/indefinido/indemma/master/components/indefinido-advisable/component.json +0 -21
- data/components/indefinido/indemma/master/components/indefinido-advisable/index.js +0 -1
- data/components/indefinido/indemma/master/components/indefinido-advisable/lib/advisable.js +0 -60
- data/components/indefinido/indemma/master/components/indefinido-observable/component.json +0 -25
- data/components/indefinido/indemma/master/components/indefinido-observable/components/cjohansen-sinon/sinon.js +0 -4290
- data/components/indefinido/indemma/master/components/indefinido-observable/lib/observable.js +0 -323
- data/components/indefinido/indemma/master/components/kapit-observe-utils/component.json +0 -13
- data/components/indefinido/indemma/master/components/paulmillr-es6-shim/component.json +0 -17
- data/components/indefinido/indemma/master/components/paulmillr-es6-shim/es6-shim.js +0 -996
- data/components/indefinido/indemma/master/components/pluma-assimilate/component.json +0 -25
- data/components/indefinido/indemma/master/components/pluma-assimilate/dist/assimilate.js +0 -127
- data/components/indefinido/indemma/master/karma.conf.js +0 -76
- data/components/indefinido/indemma/master/package.json +0 -9
- data/components/indefinido/indemma/master/spec/record/associable_spec.js +0 -137
- data/components/indefinido/indemma/master/spec/record/persistable_spec.js +0 -36
- data/components/indefinido/indemma/master/spec/record/queryable_spec.js +0 -33
- data/components/indefinido/indemma/master/spec/record/resource_spec.js +0 -93
- data/components/indefinido/indemma/master/spec/record/rest_spec.js +0 -32
- data/components/indefinido/indemma/master/spec/record/restfulable_spec.js +0 -300
- data/components/indefinido/indemma/master/spec/record/scopable_spec.js +0 -212
- data/components/indefinido/indemma/master/spec/record/storable_spec.js +0 -53
- data/components/indefinido/indemma/master/spec/record/translationable.js +0 -28
- data/components/indefinido/indemma/master/spec/record/validatable_spec.js +0 -111
- data/components/indefinido/indemma/master/spec/record/validations/associated_spec.js +0 -43
- data/components/indefinido/indemma/master/spec/record/validations/confirmation_spec.js +0 -36
- data/components/indefinido/indemma/master/spec/record/validations/cpf_spec.js +0 -35
- data/components/indefinido/indemma/master/spec/record/validations/presence_spec.js +0 -28
- data/components/indefinido/indemma/master/spec/record/validations/remote_spec.js +0 -87
- data/components/indefinido/indemma/master/spec/record/validations/type_spec.js +0 -48
- data/components/indefinido/indemma/master/spec/record_spec.js +0 -37
- data/components/indefinido/indemma/master/spec/spec_helper.js +0 -11
- data/components/indefinido/indemma/master/spec/support/value_objects/phone.js +0 -45
- data/components/indefinido/indemma/master/src/lib/extensions/rivets.coffee +0 -17
- data/components/indefinido/indemma/master/src/lib/record/associable.coffee +0 -380
- data/components/indefinido/indemma/master/src/lib/record/errors.coffee +0 -20
- data/components/indefinido/indemma/master/src/lib/record/maid.coffee +0 -16
- data/components/indefinido/indemma/master/src/lib/record/persistable.coffee +0 -32
- data/components/indefinido/indemma/master/src/lib/record/queryable.coffee +0 -30
- data/components/indefinido/indemma/master/src/lib/record/resource.coffee +0 -106
- data/components/indefinido/indemma/master/src/lib/record/rest.coffee +0 -28
- data/components/indefinido/indemma/master/src/lib/record/restfulable.coffee +0 -447
- data/components/indefinido/indemma/master/src/lib/record/scopable.coffee +0 -294
- data/components/indefinido/indemma/master/src/lib/record/storable.coffee +0 -46
- data/components/indefinido/indemma/master/src/lib/record/translationable.coffee +0 -18
- data/components/indefinido/indemma/master/src/lib/record/validatable.coffee +0 -207
- data/components/indefinido/indemma/master/src/lib/record/validations/associated.coffee +0 -30
- data/components/indefinido/indemma/master/src/lib/record/validations/confirmation.coffee +0 -17
- data/components/indefinido/indemma/master/src/lib/record/validations/cpf.coffee +0 -57
- data/components/indefinido/indemma/master/src/lib/record/validations/presence.coffee +0 -16
- data/components/indefinido/indemma/master/src/lib/record/validations/remote.coffee +0 -61
- data/components/indefinido/indemma/master/src/lib/record/validations/type.coffee +0 -31
- data/components/indefinido/indemma/master/src/lib/record/validations/validatorable.coffee +0 -5
- data/components/indefinido/indemma/master/src/lib/record.coffee +0 -138
- data/components/indefinido/indemma/master/src/spec/record/associable_spec.coffee +0 -130
- data/components/indefinido/indemma/master/src/spec/record/persistable_spec.coffee +0 -30
- data/components/indefinido/indemma/master/src/spec/record/queryable_spec.coffee +0 -27
- data/components/indefinido/indemma/master/src/spec/record/resource_spec.coffee +0 -69
- data/components/indefinido/indemma/master/src/spec/record/rest_spec.coffee +0 -22
- data/components/indefinido/indemma/master/src/spec/record/restfulable_spec.coffee +0 -215
- data/components/indefinido/indemma/master/src/spec/record/scopable_spec.coffee +0 -191
- data/components/indefinido/indemma/master/src/spec/record/storable_spec.coffee +0 -40
- data/components/indefinido/indemma/master/src/spec/record/translationable.coffee +0 -19
- data/components/indefinido/indemma/master/src/spec/record/validatable_spec.coffee +0 -100
- data/components/indefinido/indemma/master/src/spec/record/validations/associated_spec.coffee +0 -35
- data/components/indefinido/indemma/master/src/spec/record/validations/confirmation_spec.coffee +0 -25
- data/components/indefinido/indemma/master/src/spec/record/validations/cpf_spec.coffee +0 -28
- data/components/indefinido/indemma/master/src/spec/record/validations/presence_spec.coffee +0 -24
- data/components/indefinido/indemma/master/src/spec/record/validations/remote_spec.coffee +0 -74
- data/components/indefinido/indemma/master/src/spec/record/validations/type_spec.coffee +0 -33
- data/components/indefinido/indemma/master/src/spec/record_spec.coffee +0 -23
- data/components/indefinido/indemma/master/src/spec/spec_helper.coffee +0 -9
- data/components/indefinido/indemma/master/src/spec/support/value_objects/phone.coffee +0 -30
- data/components/indefinido/indemma/master/vendor/object/mixin.js +0 -196
- data/components/indefinido/indemma/master/vendor/sinon.js +0 -4290
- /data/components/indefinido/{indemma/master/components/indefinido-observable → observable/es6-modules}/index.js +0 -0
- /data/components/indefinido/{indemma/master/components/indefinido-observable → observable/es6-modules}/vendor/shims/accessors-legacy.js +0 -0
- /data/components/indefinido/{indemma/master/components/indefinido-observable → observable/es6-modules}/vendor/shims/array.indexOf.js +0 -0
- /data/components/indefinido/{indemma/master/components/indefinido-observable → observable/es6-modules}/vendor/shims/object.create.js +0 -0
@@ -1,1100 +1,227 @@
|
|
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
|
-
return "" + attribute_name + " " + options.server_message + ".";
|
40
|
-
}
|
41
|
-
},
|
42
|
-
type: function(attribute_name, options) {
|
43
|
-
attribute_name = this.human_attribute_name(attribute_name);
|
44
|
-
return "O campo " + attribute_name + " não está válido.";
|
45
|
-
}
|
46
|
-
};
|
47
|
-
|
48
|
-
errorsable = stampit({
|
49
|
-
add: function(attribute_name, message_key, options) {
|
50
|
-
var translator;
|
51
|
-
this.push([attribute_name, message_key, options]);
|
52
|
-
this.messages[attribute_name] = '';
|
53
|
-
translator = messages[message_key];
|
54
|
-
if (translator != null) {
|
55
|
-
return this.messages[attribute_name] += translator.call(this.model, attribute_name, options);
|
56
|
-
} else {
|
57
|
-
return this.messages[attribute_name] += message_key;
|
58
|
-
}
|
59
|
-
},
|
60
|
-
clear: function() {
|
61
|
-
var attribute_name, _results;
|
62
|
-
if (this.length) {
|
63
|
-
this.length = 0;
|
64
|
-
_results = [];
|
65
|
-
for (attribute_name in this.messages) {
|
66
|
-
_results.push(this.messages[attribute_name] = null);
|
67
|
-
}
|
68
|
-
return _results;
|
69
|
-
}
|
70
|
-
},
|
71
|
-
push: Array.prototype.push,
|
72
|
-
splice: Array.prototype.splice,
|
73
|
-
indexOf: Array.prototype.indexOf
|
74
|
-
}, {
|
75
|
-
model: null,
|
76
|
-
messages: null,
|
77
|
-
length: 0
|
78
|
-
}, function() {
|
79
|
-
this.messages = {};
|
80
|
-
return this;
|
81
|
-
});
|
82
|
-
|
83
|
-
initializers = {
|
84
|
-
define_triggers: function() {
|
85
|
-
this.errors = errorsable({
|
86
|
-
model: model[this.resource]
|
87
|
-
});
|
88
|
-
this.before('save', function() {
|
89
|
-
if (this.save) {
|
90
|
-
return this.validate();
|
91
|
-
}
|
92
|
-
});
|
93
|
-
this.validated = false;
|
94
|
-
this.subscribe('dirty', function(value) {
|
95
|
-
return value && (this.validated = false);
|
96
|
-
});
|
97
|
-
return Object.defineProperty(this, 'valid', {
|
98
|
-
get: function() {
|
99
|
-
this.validate();
|
100
|
-
if (this.validation.state() === 'resolved') {
|
101
|
-
return !this.errors.length;
|
102
|
-
} else {
|
103
|
-
return null;
|
104
|
-
}
|
105
|
-
},
|
106
|
-
set: function() {
|
107
|
-
throw new TypeError("You can't set the value for the valid property.");
|
108
|
-
},
|
109
|
-
enumerable: false
|
110
|
-
});
|
111
|
-
},
|
112
|
-
create_validators: function(definitions) {
|
113
|
-
var definition, name, validator, validator_options, _ref, _results;
|
114
|
-
this.validators = [];
|
115
|
-
_ref = manager.validators;
|
116
|
-
_results = [];
|
117
|
-
for (name in _ref) {
|
118
|
-
validator = _ref[name];
|
119
|
-
definition = definitions[validator.definition_key];
|
120
|
-
if (definition) {
|
121
|
-
if (type(definition) !== 'array') {
|
122
|
-
definition = [definition];
|
123
|
-
}
|
124
|
-
_results.push((function() {
|
125
|
-
var _i, _len, _results1;
|
126
|
-
_results1 = [];
|
127
|
-
for (_i = 0, _len = definition.length; _i < _len; _i++) {
|
128
|
-
validator_options = definition[_i];
|
129
|
-
if (type(validator_options) !== 'object') {
|
130
|
-
validator_options = {
|
131
|
-
attribute_name: validator_options
|
132
|
-
};
|
133
|
-
}
|
134
|
-
validator_options.model = this;
|
135
|
-
this.validators.push(validator(validator_options));
|
136
|
-
_results1.push(delete definitions[validator.definition_key]);
|
137
|
-
}
|
138
|
-
return _results1;
|
139
|
-
}).call(this));
|
140
|
-
} else {
|
141
|
-
_results.push(void 0);
|
142
|
-
}
|
143
|
-
}
|
144
|
-
return _results;
|
1
|
+
var errorsable, extensions, initializers, manager, messages, observable, root, stampit, type;
|
2
|
+
|
3
|
+
require('./translationable');
|
4
|
+
|
5
|
+
root = typeof exports !== "undefined" && exports !== null ? exports : this;
|
6
|
+
|
7
|
+
stampit = require('../../vendor/stampit');
|
8
|
+
|
9
|
+
observable = require('observable');
|
10
|
+
|
11
|
+
type = require('type');
|
12
|
+
|
13
|
+
messages = {
|
14
|
+
blank: function(attribute_name) {
|
15
|
+
attribute_name = this.human_attribute_name(attribute_name);
|
16
|
+
return "O campo " + attribute_name + " não pode ficar em branco.";
|
17
|
+
},
|
18
|
+
cpf: function(attribute_name) {
|
19
|
+
attribute_name = this.human_attribute_name(attribute_name);
|
20
|
+
return "O campo " + attribute_name + " não está válido.";
|
21
|
+
},
|
22
|
+
confirmation: function(attribute_name) {
|
23
|
+
var confirmation_attribute_name;
|
24
|
+
|
25
|
+
confirmation_attribute_name = this.human_attribute_name(attribute_name);
|
26
|
+
attribute_name = this.human_attribute_name(attribute_name.replace('_confirmation', ''));
|
27
|
+
return "O campo " + attribute_name + " não está de acordo com o campo " + confirmation_attribute_name + ".";
|
28
|
+
},
|
29
|
+
associated: function(attribute_name) {
|
30
|
+
attribute_name = this.human_attribute_name(attribute_name);
|
31
|
+
return "O registro associado " + attribute_name + " não é válido.";
|
32
|
+
},
|
33
|
+
server: function(attribute_name, options) {
|
34
|
+
if (attribute_name === 'base') {
|
35
|
+
return options.server_message;
|
36
|
+
} else {
|
37
|
+
attribute_name = this.human_attribute_name(attribute_name);
|
38
|
+
return "" + attribute_name + " " + options.server_message + ".";
|
145
39
|
}
|
146
|
-
}
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
validation = jQuery.when.apply(jQuery, results);
|
165
|
-
validation.done(doned);
|
166
|
-
validation.fail(failed);
|
167
|
-
return validation;
|
168
|
-
},
|
169
|
-
validate: function(doned, failed) {
|
170
|
-
var results, validator, _i, _len, _ref;
|
171
|
-
if (this.validated) {
|
172
|
-
return this.validation;
|
173
|
-
}
|
174
|
-
this.errors.clear();
|
175
|
-
results = [this];
|
176
|
-
_ref = model[this.resource.toString()].validators;
|
177
|
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
178
|
-
validator = _ref[_i];
|
179
|
-
results.push(validator.validate_each(this, validator.attribute_name, this[validator.attribute_name]));
|
180
|
-
}
|
181
|
-
this.validation = jQuery.when.apply(jQuery, results);
|
182
|
-
this.validation.done(doned);
|
183
|
-
this.validation.fail(failed);
|
184
|
-
return this.validation.done(function(record) {
|
185
|
-
var old_dirty;
|
186
|
-
old_dirty = record.dirty;
|
187
|
-
record.dirty = null;
|
188
|
-
record.validated || (record.validated = true);
|
189
|
-
record.observed.dirty = old_dirty;
|
190
|
-
return record;
|
191
|
-
});
|
192
|
-
}
|
40
|
+
},
|
41
|
+
type: function(attribute_name, options) {
|
42
|
+
attribute_name = this.human_attribute_name(attribute_name);
|
43
|
+
return "O campo " + attribute_name + " não está válido.";
|
44
|
+
}
|
45
|
+
};
|
46
|
+
|
47
|
+
errorsable = stampit({
|
48
|
+
add: function(attribute_name, message_key, options) {
|
49
|
+
var translator;
|
50
|
+
|
51
|
+
this.push([attribute_name, message_key, options]);
|
52
|
+
this.messages[attribute_name] = '';
|
53
|
+
translator = messages[message_key];
|
54
|
+
if (translator != null) {
|
55
|
+
return this.messages[attribute_name] += translator.call(this.model, attribute_name, options);
|
56
|
+
} else {
|
57
|
+
return this.messages[attribute_name] += message_key;
|
193
58
|
}
|
194
|
-
}
|
195
|
-
|
196
|
-
|
197
|
-
validators: {}
|
198
|
-
};
|
199
|
-
|
200
|
-
model.mix(function(modelable) {
|
201
|
-
jQuery.extend(modelable, extensions.model);
|
202
|
-
jQuery.extend(modelable.record, extensions.record);
|
203
|
-
modelable.after_mix.unshift(initializers.create_validators);
|
204
|
-
modelable.record.after_initialize.push(initializers.define_triggers);
|
205
|
-
return model.validators = manager.validators;
|
206
|
-
});
|
59
|
+
},
|
60
|
+
clear: function() {
|
61
|
+
var attribute_name, _results;
|
207
62
|
|
208
|
-
|
209
|
-
|
210
|
-
manager.validators.associated = require('./validations/associated');
|
211
|
-
|
212
|
-
manager.validators.presence = require('./validations/presence');
|
213
|
-
|
214
|
-
manager.validators.remote = require('./validations/remote');
|
215
|
-
|
216
|
-
manager.validators.type = require('./validations/type');
|
217
|
-
|
218
|
-
manager.validators.cpf = require('./validations/cpf');
|
219
|
-
|
220
|
-
}).call(this);
|
221
|
-
// Generated by CoffeeScript 1.6.3
|
222
|
-
(function() {
|
223
|
-
var errorsable, extensions, initializers, manager, messages, observable, root, stampit, type;
|
224
|
-
|
225
|
-
require('./translationable');
|
226
|
-
|
227
|
-
root = typeof exports !== "undefined" && exports !== null ? exports : this;
|
228
|
-
|
229
|
-
stampit = require('../../vendor/stampit');
|
230
|
-
|
231
|
-
observable = require('observable');
|
232
|
-
|
233
|
-
type = require('type');
|
234
|
-
|
235
|
-
messages = {
|
236
|
-
blank: function(attribute_name) {
|
237
|
-
attribute_name = this.human_attribute_name(attribute_name);
|
238
|
-
return "O campo " + attribute_name + " não pode ficar em branco.";
|
239
|
-
},
|
240
|
-
cpf: function(attribute_name) {
|
241
|
-
attribute_name = this.human_attribute_name(attribute_name);
|
242
|
-
return "O campo " + attribute_name + " não está válido.";
|
243
|
-
},
|
244
|
-
confirmation: function(attribute_name) {
|
245
|
-
var confirmation_attribute_name;
|
246
|
-
confirmation_attribute_name = this.human_attribute_name(attribute_name);
|
247
|
-
attribute_name = this.human_attribute_name(attribute_name.replace('_confirmation', ''));
|
248
|
-
return "O campo " + attribute_name + " não está de acordo com o campo " + confirmation_attribute_name + ".";
|
249
|
-
},
|
250
|
-
associated: function(attribute_name) {
|
251
|
-
attribute_name = this.human_attribute_name(attribute_name);
|
252
|
-
return "O registro associado " + attribute_name + " não é válido.";
|
253
|
-
},
|
254
|
-
server: function(attribute_name, options) {
|
255
|
-
if (attribute_name === 'base') {
|
256
|
-
return options.server_message;
|
257
|
-
} else {
|
258
|
-
attribute_name = this.human_attribute_name(attribute_name);
|
259
|
-
return "" + attribute_name + " " + options.server_message + ".";
|
260
|
-
}
|
261
|
-
},
|
262
|
-
type: function(attribute_name, options) {
|
263
|
-
attribute_name = this.human_attribute_name(attribute_name);
|
264
|
-
return "O campo " + attribute_name + " não está válido.";
|
265
|
-
}
|
266
|
-
};
|
267
|
-
|
268
|
-
errorsable = stampit({
|
269
|
-
add: function(attribute_name, message_key, options) {
|
270
|
-
var translator;
|
271
|
-
this.push([attribute_name, message_key, options]);
|
272
|
-
this.messages[attribute_name] = '';
|
273
|
-
translator = messages[message_key];
|
274
|
-
if (translator != null) {
|
275
|
-
return this.messages[attribute_name] += translator.call(this.model, attribute_name, options);
|
276
|
-
} else {
|
277
|
-
return this.messages[attribute_name] += message_key;
|
278
|
-
}
|
279
|
-
},
|
280
|
-
clear: function() {
|
281
|
-
var attribute_name, _results;
|
282
|
-
if (this.length) {
|
283
|
-
this.length = 0;
|
284
|
-
_results = [];
|
285
|
-
for (attribute_name in this.messages) {
|
286
|
-
_results.push(this.messages[attribute_name] = null);
|
287
|
-
}
|
288
|
-
return _results;
|
289
|
-
}
|
290
|
-
},
|
291
|
-
push: Array.prototype.push,
|
292
|
-
splice: Array.prototype.splice,
|
293
|
-
indexOf: Array.prototype.indexOf
|
294
|
-
}, {
|
295
|
-
model: null,
|
296
|
-
messages: null,
|
297
|
-
length: 0
|
298
|
-
}, function() {
|
299
|
-
this.messages = {};
|
300
|
-
return this;
|
301
|
-
});
|
302
|
-
|
303
|
-
initializers = {
|
304
|
-
define_triggers: function() {
|
305
|
-
this.errors = errorsable({
|
306
|
-
model: model[this.resource]
|
307
|
-
});
|
308
|
-
this.before('save', function() {
|
309
|
-
if (this.save) {
|
310
|
-
return this.validate();
|
311
|
-
}
|
312
|
-
});
|
313
|
-
this.validated = false;
|
314
|
-
this.subscribe('dirty', function(value) {
|
315
|
-
return value && (this.validated = false);
|
316
|
-
});
|
317
|
-
return Object.defineProperty(this, 'valid', {
|
318
|
-
get: function() {
|
319
|
-
this.validate();
|
320
|
-
if (this.validation.state() === 'resolved') {
|
321
|
-
return !this.errors.length;
|
322
|
-
} else {
|
323
|
-
return null;
|
324
|
-
}
|
325
|
-
},
|
326
|
-
set: function() {
|
327
|
-
throw new TypeError("You can't set the value for the valid property.");
|
328
|
-
},
|
329
|
-
enumerable: false
|
330
|
-
});
|
331
|
-
},
|
332
|
-
create_validators: function(definitions) {
|
333
|
-
var definition, name, validator, validator_options, _ref, _results;
|
334
|
-
this.validators = [];
|
335
|
-
_ref = manager.validators;
|
63
|
+
if (this.length) {
|
64
|
+
this.length = 0;
|
336
65
|
_results = [];
|
337
|
-
for (
|
338
|
-
|
339
|
-
definition = definitions[validator.definition_key];
|
340
|
-
if (definition) {
|
341
|
-
if (type(definition) !== 'array') {
|
342
|
-
definition = [definition];
|
343
|
-
}
|
344
|
-
_results.push((function() {
|
345
|
-
var _i, _len, _results1;
|
346
|
-
_results1 = [];
|
347
|
-
for (_i = 0, _len = definition.length; _i < _len; _i++) {
|
348
|
-
validator_options = definition[_i];
|
349
|
-
if (type(validator_options) !== 'object') {
|
350
|
-
validator_options = {
|
351
|
-
attribute_name: validator_options
|
352
|
-
};
|
353
|
-
}
|
354
|
-
validator_options.model = this;
|
355
|
-
this.validators.push(validator(validator_options));
|
356
|
-
_results1.push(delete definitions[validator.definition_key]);
|
357
|
-
}
|
358
|
-
return _results1;
|
359
|
-
}).call(this));
|
360
|
-
} else {
|
361
|
-
_results.push(void 0);
|
362
|
-
}
|
66
|
+
for (attribute_name in this.messages) {
|
67
|
+
_results.push(this.messages[attribute_name] = null);
|
363
68
|
}
|
364
69
|
return _results;
|
365
70
|
}
|
366
|
-
}
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
71
|
+
},
|
72
|
+
push: Array.prototype.push,
|
73
|
+
splice: Array.prototype.splice,
|
74
|
+
indexOf: Array.prototype.indexOf
|
75
|
+
}, {
|
76
|
+
model: null,
|
77
|
+
messages: null,
|
78
|
+
length: 0
|
79
|
+
}, function() {
|
80
|
+
this.messages = {};
|
81
|
+
return this;
|
82
|
+
});
|
83
|
+
|
84
|
+
initializers = {
|
85
|
+
define_triggers: function() {
|
86
|
+
this.errors = errorsable({
|
87
|
+
model: model[this.resource]
|
88
|
+
});
|
89
|
+
this.before('save', function() {
|
90
|
+
if (this.save) {
|
91
|
+
return this.validate();
|
92
|
+
}
|
93
|
+
});
|
94
|
+
this.validated = false;
|
95
|
+
this.subscribe('dirty', function(value) {
|
96
|
+
return value && (this.validated = false);
|
97
|
+
});
|
98
|
+
return Object.defineProperty(this, 'valid', {
|
99
|
+
get: function() {
|
100
|
+
this.validate();
|
101
|
+
if (this.validation.state() === 'resolved') {
|
102
|
+
return !this.errors.length;
|
103
|
+
} else {
|
104
|
+
return null;
|
383
105
|
}
|
384
|
-
validation = jQuery.when.apply(jQuery, results);
|
385
|
-
validation.done(doned);
|
386
|
-
validation.fail(failed);
|
387
|
-
return validation;
|
388
106
|
},
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
};
|
419
|
-
|
420
|
-
model.mix(function(modelable) {
|
421
|
-
jQuery.extend(modelable, extensions.model);
|
422
|
-
jQuery.extend(modelable.record, extensions.record);
|
423
|
-
modelable.after_mix.unshift(initializers.create_validators);
|
424
|
-
modelable.record.after_initialize.push(initializers.define_triggers);
|
425
|
-
return model.validators = manager.validators;
|
426
|
-
});
|
427
|
-
|
428
|
-
manager.validators.confirmation = require('./validations/confirmation');
|
429
|
-
|
430
|
-
manager.validators.associated = require('./validations/associated');
|
431
|
-
|
432
|
-
manager.validators.presence = require('./validations/presence');
|
433
|
-
|
434
|
-
manager.validators.remote = require('./validations/remote');
|
435
|
-
|
436
|
-
manager.validators.type = require('./validations/type');
|
437
|
-
|
438
|
-
manager.validators.cpf = require('./validations/cpf');
|
439
|
-
|
440
|
-
}).call(this);
|
441
|
-
// Generated by CoffeeScript 1.6.3
|
442
|
-
(function() {
|
443
|
-
var errorsable, extensions, initializers, manager, messages, observable, root, stampit, type;
|
444
|
-
|
445
|
-
require('./translationable');
|
446
|
-
|
447
|
-
root = typeof exports !== "undefined" && exports !== null ? exports : this;
|
448
|
-
|
449
|
-
stampit = require('../../vendor/stampit');
|
450
|
-
|
451
|
-
observable = require('observable');
|
452
|
-
|
453
|
-
type = require('type');
|
454
|
-
|
455
|
-
messages = {
|
456
|
-
blank: function(attribute_name) {
|
457
|
-
attribute_name = this.human_attribute_name(attribute_name);
|
458
|
-
return "O campo " + attribute_name + " não pode ficar em branco.";
|
459
|
-
},
|
460
|
-
cpf: function(attribute_name) {
|
461
|
-
attribute_name = this.human_attribute_name(attribute_name);
|
462
|
-
return "O campo " + attribute_name + " não está válido.";
|
463
|
-
},
|
464
|
-
confirmation: function(attribute_name) {
|
465
|
-
var confirmation_attribute_name;
|
466
|
-
confirmation_attribute_name = this.human_attribute_name(attribute_name);
|
467
|
-
attribute_name = this.human_attribute_name(attribute_name.replace('_confirmation', ''));
|
468
|
-
return "O campo " + attribute_name + " não está de acordo com o campo " + confirmation_attribute_name + ".";
|
469
|
-
},
|
470
|
-
associated: function(attribute_name) {
|
471
|
-
attribute_name = this.human_attribute_name(attribute_name);
|
472
|
-
return "O registro associado " + attribute_name + " não é válido.";
|
473
|
-
},
|
474
|
-
server: function(attribute_name, options) {
|
475
|
-
if (attribute_name === 'base') {
|
476
|
-
return options.server_message;
|
477
|
-
} else {
|
478
|
-
attribute_name = this.human_attribute_name(attribute_name);
|
479
|
-
return "" + attribute_name + " " + options.server_message + ".";
|
480
|
-
}
|
481
|
-
},
|
482
|
-
type: function(attribute_name, options) {
|
483
|
-
attribute_name = this.human_attribute_name(attribute_name);
|
484
|
-
return "O campo " + attribute_name + " não está válido.";
|
485
|
-
}
|
486
|
-
};
|
487
|
-
|
488
|
-
errorsable = stampit({
|
489
|
-
add: function(attribute_name, message_key, options) {
|
490
|
-
var translator;
|
491
|
-
this.push([attribute_name, message_key, options]);
|
492
|
-
this.messages[attribute_name] = '';
|
493
|
-
translator = messages[message_key];
|
494
|
-
if (translator != null) {
|
495
|
-
return this.messages[attribute_name] += translator.call(this.model, attribute_name, options);
|
496
|
-
} else {
|
497
|
-
return this.messages[attribute_name] += message_key;
|
498
|
-
}
|
499
|
-
},
|
500
|
-
clear: function() {
|
501
|
-
var attribute_name, _results;
|
502
|
-
if (this.length) {
|
503
|
-
this.length = 0;
|
504
|
-
_results = [];
|
505
|
-
for (attribute_name in this.messages) {
|
506
|
-
_results.push(this.messages[attribute_name] = null);
|
507
|
-
}
|
508
|
-
return _results;
|
509
|
-
}
|
510
|
-
},
|
511
|
-
push: Array.prototype.push,
|
512
|
-
splice: Array.prototype.splice,
|
513
|
-
indexOf: Array.prototype.indexOf
|
514
|
-
}, {
|
515
|
-
model: null,
|
516
|
-
messages: null,
|
517
|
-
length: 0
|
518
|
-
}, function() {
|
519
|
-
this.messages = {};
|
520
|
-
return this;
|
521
|
-
});
|
522
|
-
|
523
|
-
initializers = {
|
524
|
-
define_triggers: function() {
|
525
|
-
this.errors = errorsable({
|
526
|
-
model: model[this.resource]
|
527
|
-
});
|
528
|
-
this.before('save', function() {
|
529
|
-
if (this.save) {
|
530
|
-
return this.validate();
|
531
|
-
}
|
532
|
-
});
|
533
|
-
this.validated = false;
|
534
|
-
this.subscribe('dirty', function(value) {
|
535
|
-
return value && (this.validated = false);
|
536
|
-
});
|
537
|
-
return Object.defineProperty(this, 'valid', {
|
538
|
-
get: function() {
|
539
|
-
this.validate();
|
540
|
-
if (this.validation.state() === 'resolved') {
|
541
|
-
return !this.errors.length;
|
542
|
-
} else {
|
543
|
-
return null;
|
544
|
-
}
|
545
|
-
},
|
546
|
-
set: function() {
|
547
|
-
throw new TypeError("You can't set the value for the valid property.");
|
548
|
-
},
|
549
|
-
enumerable: false
|
550
|
-
});
|
551
|
-
},
|
552
|
-
create_validators: function(definitions) {
|
553
|
-
var definition, name, validator, validator_options, _ref, _results;
|
554
|
-
this.validators = [];
|
555
|
-
_ref = manager.validators;
|
556
|
-
_results = [];
|
557
|
-
for (name in _ref) {
|
558
|
-
validator = _ref[name];
|
559
|
-
definition = definitions[validator.definition_key];
|
560
|
-
if (definition) {
|
561
|
-
if (type(definition) !== 'array') {
|
562
|
-
definition = [definition];
|
563
|
-
}
|
564
|
-
_results.push((function() {
|
565
|
-
var _i, _len, _results1;
|
566
|
-
_results1 = [];
|
567
|
-
for (_i = 0, _len = definition.length; _i < _len; _i++) {
|
568
|
-
validator_options = definition[_i];
|
569
|
-
if (type(validator_options) !== 'object') {
|
570
|
-
validator_options = {
|
571
|
-
attribute_name: validator_options
|
572
|
-
};
|
573
|
-
}
|
574
|
-
validator_options.model = this;
|
575
|
-
this.validators.push(validator(validator_options));
|
576
|
-
_results1.push(delete definitions[validator.definition_key]);
|
107
|
+
set: function() {
|
108
|
+
throw new TypeError("You can't set the value for the valid property.");
|
109
|
+
},
|
110
|
+
enumerable: false
|
111
|
+
});
|
112
|
+
},
|
113
|
+
create_validators: function(definitions) {
|
114
|
+
var definition, name, validator, validator_options, _ref, _results;
|
115
|
+
|
116
|
+
this.validators = [];
|
117
|
+
_ref = manager.validators;
|
118
|
+
_results = [];
|
119
|
+
for (name in _ref) {
|
120
|
+
validator = _ref[name];
|
121
|
+
definition = definitions[validator.definition_key];
|
122
|
+
if (definition) {
|
123
|
+
if (type(definition) !== 'array') {
|
124
|
+
definition = [definition];
|
125
|
+
}
|
126
|
+
_results.push((function() {
|
127
|
+
var _i, _len, _results1;
|
128
|
+
|
129
|
+
_results1 = [];
|
130
|
+
for (_i = 0, _len = definition.length; _i < _len; _i++) {
|
131
|
+
validator_options = definition[_i];
|
132
|
+
if (type(validator_options) !== 'object') {
|
133
|
+
validator_options = {
|
134
|
+
attribute_name: validator_options
|
135
|
+
};
|
577
136
|
}
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
_results.push(void 0);
|
582
|
-
}
|
583
|
-
}
|
584
|
-
return _results;
|
585
|
-
}
|
586
|
-
};
|
587
|
-
|
588
|
-
extensions = {
|
589
|
-
model: {
|
590
|
-
validators: null
|
591
|
-
},
|
592
|
-
record: {
|
593
|
-
validate_attribute: function(attribute, doned, failed) {
|
594
|
-
var results, validation, validator, _i, _len, _ref;
|
595
|
-
this.errors.messages[attribute] = null;
|
596
|
-
results = [this, attribute];
|
597
|
-
_ref = model[this.resource.toString()].validators;
|
598
|
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
599
|
-
validator = _ref[_i];
|
600
|
-
if (validator.attribute_name === attribute) {
|
601
|
-
results.push(validator.validate_each(this, validator.attribute_name, this[validator.attribute_name]));
|
137
|
+
validator_options.model = this;
|
138
|
+
this.validators.push(validator(validator_options));
|
139
|
+
_results1.push(delete definitions[validator.definition_key]);
|
602
140
|
}
|
603
|
-
|
604
|
-
|
605
|
-
validation.done(doned);
|
606
|
-
validation.fail(failed);
|
607
|
-
return validation;
|
608
|
-
},
|
609
|
-
validate: function(doned, failed) {
|
610
|
-
var results, validator, _i, _len, _ref;
|
611
|
-
if (this.validated) {
|
612
|
-
return this.validation;
|
613
|
-
}
|
614
|
-
this.errors.clear();
|
615
|
-
results = [this];
|
616
|
-
_ref = model[this.resource.toString()].validators;
|
617
|
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
618
|
-
validator = _ref[_i];
|
619
|
-
results.push(validator.validate_each(this, validator.attribute_name, this[validator.attribute_name]));
|
620
|
-
}
|
621
|
-
this.validation = jQuery.when.apply(jQuery, results);
|
622
|
-
this.validation.done(doned);
|
623
|
-
this.validation.fail(failed);
|
624
|
-
return this.validation.done(function(record) {
|
625
|
-
var old_dirty;
|
626
|
-
old_dirty = record.dirty;
|
627
|
-
record.dirty = null;
|
628
|
-
record.validated || (record.validated = true);
|
629
|
-
record.observed.dirty = old_dirty;
|
630
|
-
return record;
|
631
|
-
});
|
632
|
-
}
|
633
|
-
}
|
634
|
-
};
|
635
|
-
|
636
|
-
manager = {
|
637
|
-
validators: {}
|
638
|
-
};
|
639
|
-
|
640
|
-
model.mix(function(modelable) {
|
641
|
-
jQuery.extend(modelable, extensions.model);
|
642
|
-
jQuery.extend(modelable.record, extensions.record);
|
643
|
-
modelable.after_mix.unshift(initializers.create_validators);
|
644
|
-
modelable.record.after_initialize.push(initializers.define_triggers);
|
645
|
-
return model.validators = manager.validators;
|
646
|
-
});
|
647
|
-
|
648
|
-
manager.validators.confirmation = require('./validations/confirmation');
|
649
|
-
|
650
|
-
manager.validators.associated = require('./validations/associated');
|
651
|
-
|
652
|
-
manager.validators.presence = require('./validations/presence');
|
653
|
-
|
654
|
-
manager.validators.remote = require('./validations/remote');
|
655
|
-
|
656
|
-
manager.validators.type = require('./validations/type');
|
657
|
-
|
658
|
-
manager.validators.cpf = require('./validations/cpf');
|
659
|
-
|
660
|
-
}).call(this);
|
661
|
-
// Generated by CoffeeScript 1.6.3
|
662
|
-
(function() {
|
663
|
-
var errorsable, extensions, initializers, manager, messages, observable, root, stampit, type;
|
664
|
-
|
665
|
-
require('./translationable');
|
666
|
-
|
667
|
-
root = typeof exports !== "undefined" && exports !== null ? exports : this;
|
668
|
-
|
669
|
-
stampit = require('../../vendor/stampit');
|
670
|
-
|
671
|
-
observable = require('observable');
|
672
|
-
|
673
|
-
type = require('type');
|
674
|
-
|
675
|
-
messages = {
|
676
|
-
blank: function(attribute_name) {
|
677
|
-
attribute_name = this.human_attribute_name(attribute_name);
|
678
|
-
return "O campo " + attribute_name + " não pode ficar em branco.";
|
679
|
-
},
|
680
|
-
cpf: function(attribute_name) {
|
681
|
-
attribute_name = this.human_attribute_name(attribute_name);
|
682
|
-
return "O campo " + attribute_name + " não está válido.";
|
683
|
-
},
|
684
|
-
confirmation: function(attribute_name) {
|
685
|
-
var confirmation_attribute_name;
|
686
|
-
confirmation_attribute_name = this.human_attribute_name(attribute_name);
|
687
|
-
attribute_name = this.human_attribute_name(attribute_name.replace('_confirmation', ''));
|
688
|
-
return "O campo " + attribute_name + " não está de acordo com o campo " + confirmation_attribute_name + ".";
|
689
|
-
},
|
690
|
-
associated: function(attribute_name) {
|
691
|
-
attribute_name = this.human_attribute_name(attribute_name);
|
692
|
-
return "O registro associado " + attribute_name + " não é válido.";
|
693
|
-
},
|
694
|
-
server: function(attribute_name, options) {
|
695
|
-
if (attribute_name === 'base') {
|
696
|
-
return options.server_message;
|
141
|
+
return _results1;
|
142
|
+
}).call(this));
|
697
143
|
} else {
|
698
|
-
|
699
|
-
return "" + attribute_name + " " + options.server_message + ".";
|
144
|
+
_results.push(void 0);
|
700
145
|
}
|
701
|
-
},
|
702
|
-
type: function(attribute_name, options) {
|
703
|
-
attribute_name = this.human_attribute_name(attribute_name);
|
704
|
-
return "O campo " + attribute_name + " não está válido.";
|
705
146
|
}
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
_results = [];
|
725
|
-
for (attribute_name in this.messages) {
|
726
|
-
_results.push(this.messages[attribute_name] = null);
|
727
|
-
}
|
728
|
-
return _results;
|
729
|
-
}
|
730
|
-
},
|
731
|
-
push: Array.prototype.push,
|
732
|
-
splice: Array.prototype.splice,
|
733
|
-
indexOf: Array.prototype.indexOf
|
734
|
-
}, {
|
735
|
-
model: null,
|
736
|
-
messages: null,
|
737
|
-
length: 0
|
738
|
-
}, function() {
|
739
|
-
this.messages = {};
|
740
|
-
return this;
|
741
|
-
});
|
742
|
-
|
743
|
-
initializers = {
|
744
|
-
define_triggers: function() {
|
745
|
-
this.errors = errorsable({
|
746
|
-
model: model[this.resource]
|
747
|
-
});
|
748
|
-
this.before('save', function() {
|
749
|
-
if (this.save) {
|
750
|
-
return this.validate();
|
751
|
-
}
|
752
|
-
});
|
753
|
-
this.validated = false;
|
754
|
-
this.subscribe('dirty', function(value) {
|
755
|
-
return value && (this.validated = false);
|
756
|
-
});
|
757
|
-
return Object.defineProperty(this, 'valid', {
|
758
|
-
get: function() {
|
759
|
-
this.validate();
|
760
|
-
if (this.validation.state() === 'resolved') {
|
761
|
-
return !this.errors.length;
|
762
|
-
} else {
|
763
|
-
return null;
|
764
|
-
}
|
765
|
-
},
|
766
|
-
set: function() {
|
767
|
-
throw new TypeError("You can't set the value for the valid property.");
|
768
|
-
},
|
769
|
-
enumerable: false
|
770
|
-
});
|
771
|
-
},
|
772
|
-
create_validators: function(definitions) {
|
773
|
-
var definition, name, validator, validator_options, _ref, _results;
|
774
|
-
this.validators = [];
|
775
|
-
_ref = manager.validators;
|
776
|
-
_results = [];
|
777
|
-
for (name in _ref) {
|
778
|
-
validator = _ref[name];
|
779
|
-
definition = definitions[validator.definition_key];
|
780
|
-
if (definition) {
|
781
|
-
if (type(definition) !== 'array') {
|
782
|
-
definition = [definition];
|
783
|
-
}
|
784
|
-
_results.push((function() {
|
785
|
-
var _i, _len, _results1;
|
786
|
-
_results1 = [];
|
787
|
-
for (_i = 0, _len = definition.length; _i < _len; _i++) {
|
788
|
-
validator_options = definition[_i];
|
789
|
-
if (type(validator_options) !== 'object') {
|
790
|
-
validator_options = {
|
791
|
-
attribute_name: validator_options
|
792
|
-
};
|
793
|
-
}
|
794
|
-
validator_options.model = this;
|
795
|
-
this.validators.push(validator(validator_options));
|
796
|
-
_results1.push(delete definitions[validator.definition_key]);
|
797
|
-
}
|
798
|
-
return _results1;
|
799
|
-
}).call(this));
|
800
|
-
} else {
|
801
|
-
_results.push(void 0);
|
802
|
-
}
|
803
|
-
}
|
804
|
-
return _results;
|
805
|
-
}
|
806
|
-
};
|
807
|
-
|
808
|
-
extensions = {
|
809
|
-
model: {
|
810
|
-
validators: null
|
811
|
-
},
|
812
|
-
record: {
|
813
|
-
validate_attribute: function(attribute, doned, failed) {
|
814
|
-
var results, validation, validator, _i, _len, _ref;
|
815
|
-
this.errors.messages[attribute] = null;
|
816
|
-
results = [this, attribute];
|
817
|
-
_ref = model[this.resource.toString()].validators;
|
818
|
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
819
|
-
validator = _ref[_i];
|
820
|
-
if (validator.attribute_name === attribute) {
|
821
|
-
results.push(validator.validate_each(this, validator.attribute_name, this[validator.attribute_name]));
|
822
|
-
}
|
823
|
-
}
|
824
|
-
validation = jQuery.when.apply(jQuery, results);
|
825
|
-
validation.done(doned);
|
826
|
-
validation.fail(failed);
|
827
|
-
return validation;
|
828
|
-
},
|
829
|
-
validate: function(doned, failed) {
|
830
|
-
var results, validator, _i, _len, _ref;
|
831
|
-
if (this.validated) {
|
832
|
-
return this.validation;
|
833
|
-
}
|
834
|
-
this.errors.clear();
|
835
|
-
results = [this];
|
836
|
-
_ref = model[this.resource.toString()].validators;
|
837
|
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
838
|
-
validator = _ref[_i];
|
147
|
+
return _results;
|
148
|
+
}
|
149
|
+
};
|
150
|
+
|
151
|
+
extensions = {
|
152
|
+
model: {
|
153
|
+
validators: null
|
154
|
+
},
|
155
|
+
record: {
|
156
|
+
validate_attribute: function(attribute, doned, failed) {
|
157
|
+
var results, validation, validator, _i, _len, _ref;
|
158
|
+
|
159
|
+
this.errors.messages[attribute] = null;
|
160
|
+
results = [this, attribute];
|
161
|
+
_ref = model[this.resource.toString()].validators;
|
162
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
163
|
+
validator = _ref[_i];
|
164
|
+
if (validator.attribute_name === attribute) {
|
839
165
|
results.push(validator.validate_each(this, validator.attribute_name, this[validator.attribute_name]));
|
840
166
|
}
|
841
|
-
this.validation = jQuery.when.apply(jQuery, results);
|
842
|
-
this.validation.done(doned);
|
843
|
-
this.validation.fail(failed);
|
844
|
-
return this.validation.done(function(record) {
|
845
|
-
var old_dirty;
|
846
|
-
old_dirty = record.dirty;
|
847
|
-
record.dirty = null;
|
848
|
-
record.validated || (record.validated = true);
|
849
|
-
record.observed.dirty = old_dirty;
|
850
|
-
return record;
|
851
|
-
});
|
852
167
|
}
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
validators: {}
|
858
|
-
};
|
859
|
-
|
860
|
-
model.mix(function(modelable) {
|
861
|
-
jQuery.extend(modelable, extensions.model);
|
862
|
-
jQuery.extend(modelable.record, extensions.record);
|
863
|
-
modelable.after_mix.unshift(initializers.create_validators);
|
864
|
-
modelable.record.after_initialize.push(initializers.define_triggers);
|
865
|
-
return model.validators = manager.validators;
|
866
|
-
});
|
867
|
-
|
868
|
-
manager.validators.confirmation = require('./validations/confirmation');
|
869
|
-
|
870
|
-
manager.validators.associated = require('./validations/associated');
|
871
|
-
|
872
|
-
manager.validators.presence = require('./validations/presence');
|
873
|
-
|
874
|
-
manager.validators.remote = require('./validations/remote');
|
875
|
-
|
876
|
-
manager.validators.type = require('./validations/type');
|
877
|
-
|
878
|
-
manager.validators.cpf = require('./validations/cpf');
|
879
|
-
|
880
|
-
}).call(this);
|
881
|
-
// Generated by CoffeeScript 1.6.3
|
882
|
-
(function() {
|
883
|
-
var errorsable, extensions, initializers, manager, messages, observable, root, stampit, type;
|
884
|
-
|
885
|
-
require('./translationable');
|
886
|
-
|
887
|
-
root = typeof exports !== "undefined" && exports !== null ? exports : this;
|
888
|
-
|
889
|
-
stampit = require('../../vendor/stampit');
|
890
|
-
|
891
|
-
observable = require('observable');
|
892
|
-
|
893
|
-
type = require('type');
|
894
|
-
|
895
|
-
messages = {
|
896
|
-
blank: function(attribute_name) {
|
897
|
-
attribute_name = this.human_attribute_name(attribute_name);
|
898
|
-
return "O campo " + attribute_name + " não pode ficar em branco.";
|
899
|
-
},
|
900
|
-
cpf: function(attribute_name) {
|
901
|
-
attribute_name = this.human_attribute_name(attribute_name);
|
902
|
-
return "O campo " + attribute_name + " não está válido.";
|
903
|
-
},
|
904
|
-
confirmation: function(attribute_name) {
|
905
|
-
var confirmation_attribute_name;
|
906
|
-
confirmation_attribute_name = this.human_attribute_name(attribute_name);
|
907
|
-
attribute_name = this.human_attribute_name(attribute_name.replace('_confirmation', ''));
|
908
|
-
return "O campo " + attribute_name + " não está de acordo com o campo " + confirmation_attribute_name + ".";
|
909
|
-
},
|
910
|
-
associated: function(attribute_name) {
|
911
|
-
attribute_name = this.human_attribute_name(attribute_name);
|
912
|
-
return "O registro associado " + attribute_name + " não é válido.";
|
168
|
+
validation = jQuery.when.apply(jQuery, results);
|
169
|
+
validation.done(doned);
|
170
|
+
validation.fail(failed);
|
171
|
+
return validation;
|
913
172
|
},
|
914
|
-
|
915
|
-
|
916
|
-
return options.server_message;
|
917
|
-
} else {
|
918
|
-
attribute_name = this.human_attribute_name(attribute_name);
|
919
|
-
return "" + attribute_name + " " + options.server_message + ".";
|
920
|
-
}
|
921
|
-
},
|
922
|
-
type: function(attribute_name, options) {
|
923
|
-
attribute_name = this.human_attribute_name(attribute_name);
|
924
|
-
return "O campo " + attribute_name + " não está válido.";
|
925
|
-
}
|
926
|
-
};
|
173
|
+
validate: function(doned, failed) {
|
174
|
+
var results, validator, _i, _len, _ref;
|
927
175
|
|
928
|
-
|
929
|
-
|
930
|
-
var translator;
|
931
|
-
this.push([attribute_name, message_key, options]);
|
932
|
-
this.messages[attribute_name] = '';
|
933
|
-
translator = messages[message_key];
|
934
|
-
if (translator != null) {
|
935
|
-
return this.messages[attribute_name] += translator.call(this.model, attribute_name, options);
|
936
|
-
} else {
|
937
|
-
return this.messages[attribute_name] += message_key;
|
176
|
+
if (this.validated) {
|
177
|
+
return this.validation;
|
938
178
|
}
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
for (attribute_name in this.messages) {
|
946
|
-
_results.push(this.messages[attribute_name] = null);
|
947
|
-
}
|
948
|
-
return _results;
|
179
|
+
this.errors.clear();
|
180
|
+
results = [this];
|
181
|
+
_ref = model[this.resource.toString()].validators;
|
182
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
183
|
+
validator = _ref[_i];
|
184
|
+
results.push(validator.validate_each(this, validator.attribute_name, this[validator.attribute_name]));
|
949
185
|
}
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
model: null,
|
956
|
-
messages: null,
|
957
|
-
length: 0
|
958
|
-
}, function() {
|
959
|
-
this.messages = {};
|
960
|
-
return this;
|
961
|
-
});
|
186
|
+
this.validation = jQuery.when.apply(jQuery, results);
|
187
|
+
this.validation.done(doned);
|
188
|
+
this.validation.fail(failed);
|
189
|
+
return this.validation.done(function(record) {
|
190
|
+
var old_dirty;
|
962
191
|
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
192
|
+
old_dirty = record.dirty;
|
193
|
+
record.dirty = null;
|
194
|
+
record.validated || (record.validated = true);
|
195
|
+
record.observed.dirty = old_dirty;
|
196
|
+
return record;
|
967
197
|
});
|
968
|
-
this.before('save', function() {
|
969
|
-
if (this.save) {
|
970
|
-
return this.validate();
|
971
|
-
}
|
972
|
-
});
|
973
|
-
this.validated = false;
|
974
|
-
this.subscribe('dirty', function(value) {
|
975
|
-
return value && (this.validated = false);
|
976
|
-
});
|
977
|
-
return Object.defineProperty(this, 'valid', {
|
978
|
-
get: function() {
|
979
|
-
this.validate();
|
980
|
-
if (this.validation.state() === 'resolved') {
|
981
|
-
return !this.errors.length;
|
982
|
-
} else {
|
983
|
-
return null;
|
984
|
-
}
|
985
|
-
},
|
986
|
-
set: function() {
|
987
|
-
throw new TypeError("You can't set the value for the valid property.");
|
988
|
-
},
|
989
|
-
enumerable: false
|
990
|
-
});
|
991
|
-
},
|
992
|
-
create_validators: function(definitions) {
|
993
|
-
var definition, name, validator, validator_options, _ref, _results;
|
994
|
-
this.validators = [];
|
995
|
-
_ref = manager.validators;
|
996
|
-
_results = [];
|
997
|
-
for (name in _ref) {
|
998
|
-
validator = _ref[name];
|
999
|
-
definition = definitions[validator.definition_key];
|
1000
|
-
if (definition) {
|
1001
|
-
if (type(definition) !== 'array') {
|
1002
|
-
definition = [definition];
|
1003
|
-
}
|
1004
|
-
_results.push((function() {
|
1005
|
-
var _i, _len, _results1;
|
1006
|
-
_results1 = [];
|
1007
|
-
for (_i = 0, _len = definition.length; _i < _len; _i++) {
|
1008
|
-
validator_options = definition[_i];
|
1009
|
-
if (type(validator_options) !== 'object') {
|
1010
|
-
validator_options = {
|
1011
|
-
attribute_name: validator_options
|
1012
|
-
};
|
1013
|
-
}
|
1014
|
-
validator_options.model = this;
|
1015
|
-
this.validators.push(validator(validator_options));
|
1016
|
-
_results1.push(delete definitions[validator.definition_key]);
|
1017
|
-
}
|
1018
|
-
return _results1;
|
1019
|
-
}).call(this));
|
1020
|
-
} else {
|
1021
|
-
_results.push(void 0);
|
1022
|
-
}
|
1023
|
-
}
|
1024
|
-
return _results;
|
1025
|
-
}
|
1026
|
-
};
|
1027
|
-
|
1028
|
-
extensions = {
|
1029
|
-
model: {
|
1030
|
-
validators: null
|
1031
|
-
},
|
1032
|
-
record: {
|
1033
|
-
validate_attribute: function(attribute, doned, failed) {
|
1034
|
-
var results, validation, validator, _i, _len, _ref;
|
1035
|
-
this.errors.messages[attribute] = null;
|
1036
|
-
results = [this, attribute];
|
1037
|
-
_ref = model[this.resource.toString()].validators;
|
1038
|
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
1039
|
-
validator = _ref[_i];
|
1040
|
-
if (validator.attribute_name === attribute) {
|
1041
|
-
results.push(validator.validate_each(this, validator.attribute_name, this[validator.attribute_name]));
|
1042
|
-
}
|
1043
|
-
}
|
1044
|
-
validation = jQuery.when.apply(jQuery, results);
|
1045
|
-
validation.done(doned);
|
1046
|
-
validation.fail(failed);
|
1047
|
-
return validation;
|
1048
|
-
},
|
1049
|
-
validate: function(doned, failed) {
|
1050
|
-
var results, validator, _i, _len, _ref;
|
1051
|
-
if (this.validated) {
|
1052
|
-
return this.validation;
|
1053
|
-
}
|
1054
|
-
this.errors.clear();
|
1055
|
-
results = [this];
|
1056
|
-
_ref = model[this.resource.toString()].validators;
|
1057
|
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
1058
|
-
validator = _ref[_i];
|
1059
|
-
results.push(validator.validate_each(this, validator.attribute_name, this[validator.attribute_name]));
|
1060
|
-
}
|
1061
|
-
this.validation = jQuery.when.apply(jQuery, results);
|
1062
|
-
this.validation.done(doned);
|
1063
|
-
this.validation.fail(failed);
|
1064
|
-
return this.validation.done(function(record) {
|
1065
|
-
var old_dirty;
|
1066
|
-
old_dirty = record.dirty;
|
1067
|
-
record.dirty = null;
|
1068
|
-
record.validated || (record.validated = true);
|
1069
|
-
record.observed.dirty = old_dirty;
|
1070
|
-
return record;
|
1071
|
-
});
|
1072
|
-
}
|
1073
198
|
}
|
1074
|
-
}
|
1075
|
-
|
1076
|
-
manager = {
|
1077
|
-
validators: {}
|
1078
|
-
};
|
199
|
+
}
|
200
|
+
};
|
1079
201
|
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
modelable.after_mix.unshift(initializers.create_validators);
|
1084
|
-
modelable.record.after_initialize.push(initializers.define_triggers);
|
1085
|
-
return model.validators = manager.validators;
|
1086
|
-
});
|
202
|
+
manager = {
|
203
|
+
validators: {}
|
204
|
+
};
|
1087
205
|
|
1088
|
-
|
206
|
+
model.mix(function(modelable) {
|
207
|
+
if (modelable.record.validate) {
|
208
|
+
return;
|
209
|
+
}
|
210
|
+
jQuery.extend(modelable, extensions.model);
|
211
|
+
jQuery.extend(modelable.record, extensions.record);
|
212
|
+
modelable.after_mix.unshift(initializers.create_validators);
|
213
|
+
modelable.record.after_initialize.push(initializers.define_triggers);
|
214
|
+
return model.validators = manager.validators;
|
215
|
+
});
|
1089
216
|
|
1090
|
-
|
217
|
+
manager.validators.confirmation = require('./validations/confirmation');
|
1091
218
|
|
1092
|
-
|
219
|
+
manager.validators.associated = require('./validations/associated');
|
1093
220
|
|
1094
|
-
|
221
|
+
manager.validators.presence = require('./validations/presence');
|
1095
222
|
|
1096
|
-
|
223
|
+
manager.validators.remote = require('./validations/remote');
|
1097
224
|
|
1098
|
-
|
225
|
+
manager.validators.type = require('./validations/type');
|
1099
226
|
|
1100
|
-
|
227
|
+
manager.validators.cpf = require('./validations/cpf');
|