Here是從文檔: User.validate('name', customValidator, {message: 'Bad name'});
function customValidator(err) {
if (this.name === 'bad') err();
});
var user = new User({name: 'Peter'});
user.isValid
考慮以下示例: 假設有一個對象具有enum屬性。如果enum財產具有5值,則字段value應該等於5,如果enum是super對象必須具有屬性up和down。因此,js代碼可以是這樣的: if (obj.enum === 5) {
if (obj.value != 5) {
//error here
}
}
if (obj.enum === 'super')
我想定義一個遠程方法具有以下路徑: http://localhost:3000/api/dataSourceTestings/(編號)/一個 In the dataSourceTesting.json file I defined its path as :
"http": [
{
"path": "/{id}/a",
"verb": "put"