Stores the results of one or more validation operations
A validation result starts out representing a successful operation. Calls to addError will change success to false, and store the error. Multiple ValidationResult objects can be merged via the merge function, allowing several operations to return a single result object. ValidationResult is primarily used to return information to the browser regarding the status of an AJAX call, and ValidationResult.toJson() will return an appropriate JSON string for an Ext form submit action. ValidationResult objects are also returned by Myna.DataManager.beanTemplate “set” functions
Myna.DataManager.beanTemplate.setFields=function(fields){
var bean = this;
var result = new Myna.ValidationResult();
fields.getKeys().forEach(function(name){
if (bean.columnNames.indexOf(name) != -1){
result.merge(bean["set_"+name](fields[name]));
}
})
return result;
}
bean.baseBean["set_"+fname] = function (newval){
var result = new Myna.ValidationResult();
if (typeof newval === "undefined"){
result.addError("argument 'newval' required for set" +fname +".",fname);
return result;
}
if (newval != this.data[arguments.callee.fieldName]){
result.merge(this.saveField(arguments.callee.fieldName,newval));
this.data[arguments.callee.fieldName] = newval;
}
return result;
}| Myna. ValidationResult | Stores the results of one or more validation operations |
| Functions | |
| Myna. ValidationResult | Contructs a ValidationResult Object |
| Properties | |
| success | Boolean result status for this ValidationResult default true |
| errors | object containing errors keyed by property name default {} |
| errorMessage | Overall error message for this ValidationResult |
| errorDetail | All messages added via addError without a property parameter |
| Functions | |
| addError | Adds an error to this result and sets success to false |
| merge | Merge a ValidationResult into this one, optionally changing the errors properties |
Myna.ValidationResult = function( validation )
Contructs a ValidationResult Object
| validation | Optional default undefined a ValidationResult object to act as the base for this object |
Boolean result status for this ValidationResult default true
This is set to false automatically when addError is called, or a ValidationResult object with success=false is merged
object containing errors keyed by property name default {}
Errors are added to this object automatically when addError is called with a property parameter
All messages added via addError without a property parameter
Myna.ValidationResult.prototype.merge=function( validation, prefix )
Merge a ValidationResult into this one, optionally changing the errors properties
| validation | a ValidationResult object to merge wit this one |
| prefix | Optional default undefined If defined, this string will be prepended to the validation.errors before merging |
Contructs a ValidationResult Object
Myna.ValidationResult = function( validation )
Adds an error to this result and sets success to false
Myna.ValidationResult.prototype.addError=function( message, property )
Merge a ValidationResult into this one, optionally changing the errors properties
Myna.ValidationResult.prototype.merge=function( validation, prefix )