4
A
回答
5
据文档,It simply ensures that the field has a value.
首先定义一个雇员模型像的下方。
Ext.define('App.model.Employee', {
extend: 'Ext.data.Model',
config: {
fields: [
{ name: 'id', type: 'int' },
{ name: 'name', type: 'string' },
{ name: 'salary', type: 'float' },
{ name: 'address', type: 'string' },
],
validations: [
{ type: 'presence', field: 'name' }
]
}
});
现在创建一个先前创建的Employee模型的实例。 请注意,我们没有将值分配给名称字段,该字段具有存在验证。
var newEmployee = Ext.create('App.model.Employee', {
id: 1,
salary: 5555.00,
address: 'Noida'
});
// Validating a model.
var errors = newEmployee.validate();
//Now print the error message
errors.each(function (item, index, length) {
console.log('Field "' + item.getField() + '" ' + item.getMessage());//Field "name" must be present
});
相关问题
- 1. 什么是SQL级验证和模型级验证在轨
- 2. 在Ave中验证插件类型时,默认值是什么?
- 3. Rails的“验证”是什么类型的语言结构?
- 4. GAE中的“认证类型”是什么
- 5. “验证分支”是什么?
- 6. 什么是jQuery Unobtrusive验证?
- 7. 为什么在子类型表单上的验证会中断?
- 8. 为什么在REST请求中验证内容类型标头
- 9. 什么类型是HashMap存储桶
- 10. Erlang验证记录类型是否存在?
- 11. 是否存在Haskell无法验证的类型签名?
- 12. 什么是?类型?
- 13. 在测试什么是验证的假?
- 14. 验证码失败,现在是什么?
- 15. 在PHP模型验证的常见模式是什么?
- 16. 内存泄漏:验证块类型
- 17. 为什么使用Schema验证XML时未验证数据类型?
- 18. 什么是类型和什么是类型构造函数scala
- 19. 为什么git的pre-commit hook会验证HEAD是否存在?
- 20. Java:验证类存在
- 21. 验证对泛型类型
- 22. xml验证:验证URI类型
- 23. 为什么bean验证Min/Max约束不支持double类型?
- 24. 验证是否存在
- 25. 为什么好友类用于验证?
- 26. 在Ruby on Rails模型中,为什么存在已验证关联但在外键上验证了唯一性
- 27. 用于输入验证的最佳泛型类或包是什么?
- 28. 使用单表继承(STI)时验证类型的正确方法是什么?
- 29. 验证失败时抛出Spring RestController的异常类型是什么?
- 30. Magento验证类验证号与验证号之间有什么区别
谢谢你的帮助 – 2014-09-27 07:53:23