域和组件级别的验证 vadacl
- 授权协议: 未知
- 开发语言: TypeScript
- 操作系统: 跨平台
- 软件首页: https://github.com/bcswartz/vadacl
- 软件文档: https://github.com/bcswartz/vadacl/blob/master/README.md
- 官方下载: https://github.com/bcswartz/vadacl/archive/master.zip
软件介绍
vadacl ("validation at domain and component levels")是一个基于 TypeScript 的代码库,能提高 Angular 2 形式类验证功能。它提供了一种方法让开发人员可以对数据对象设置基于域或数据库的验证规则,然后在不同的组件需要的时候增加或替换这些验证。它还可以让开发人员添加和重写那些已添加的验证错误消息,验证方法返回验证元数据中。
示例代码:
import { Validatable, PropertyValidations } from '../vadacl/interfaces'
export class UserProfile implements Validatable {
firstName: string = null;
lastName: string = null;
username: string = null;
age: number = null;
gender: string = null;
validations: { [ index: string ] : PropertyValidations } = {
firstName: {
maxLength: { maxLength: 25, message: 'Your first name cannot be longer than 25 characters.'},
required: { message: 'Your first name is required.' }
},
lastName: {
maxLength: { maxLength: 25, message: 'Your last name cannot be longer than 25 characters.'},
required: { message: 'Your last name is required.' }
},
username: {
maxLength: { maxLength: 30, message: 'Your username cannot be longer than 25 characters.'},
required: { message: 'You must have a username.' }
},
age: {
pattern: { pattern: '[0-9]*', message: 'Enter your age as an integer.' }
},
gender: {
pattern: { pattern: 'M|F', message: 'Enter your gender as "M" or "F".' }
}
};
}未来发展:
添加单元测试。 增加更多的验证方法。 添加在消息模块中设置域级验证错误消息的能力,以适应国际化。
Web Development Recipes
Brian P. Hogan、Chris Warren、Mike Weber、Chris Johnson、Aaron Godin / Pragmatic Bookshelf / 2012-1-22 / USD 35.00
You'll see a full spectrum of cutting-edge web development techniques, from UI and eye candy recipes to solutions for data analysis, testing, and web hosting. Make buttons and content stand out with s......一起来看看 《Web Development Recipes》 这本书的介绍吧!
