May I suggest one more change?
In Form.Validator.Inline function insertAdvice
change this:
if (field.type.toLowerCase() == 'radio')
field.getParent().adopt(advice);
for this:
if (field.type && field.type.toLowerCase() === 'radio')
field.getParent().adopt(advice);
insertAdvice: function(advice, field) {
//Check for error position prop
var props = field.get('validatorProps');
//Build advice
if (!props.msgPos || !document.id(props.msgPos)) {
if (field.type && field.type.toLowerCase() == 'radio')
field.getParent().adopt(advice);
else advice.inject(document.id(field), 'after');
} else {
document.id(props.msgPos).grab(advice);
}
},
this would allow me to set validators to elements like "div", for
example:
Form.Validator.add('rs-div-required', {
errorMsg: function() {
return Form.Validator.getMsg('required');
},
test: function(element) {
return !((element.get('text') == null) ||
(element.get('text').length == 0));
}
});
I am using them for fields with complex data (images, date-ranges,
etc).