【发布时间】:2015-03-22 16:49:48
【问题描述】:
我正在编写一个来自 PHP 背景的 Angular 应用程序。我想知道是否有任何好的断言/验证库可以用来帮助我验证传递给我的模型的参数,例如Validate.isNumber(data.id) 并在失败时自动抛出适当的异常
app.factory('Something', ['moment', function(moment){
function Something(data) {
// validate data has required properties and they are of the expected type!!!
this.id = data.id;
this.title = data.title;
this.description = data.description;
}
Something.prototype.getId = function () {
return this.id;
};
Something.prototype.getTitle = function () {
return this.title;
};
Something.prototype.getDescription = function () {
return this.description;
};
return Something;
}]);
【问题讨论】:
标签: javascript angularjs validation