自定义规则对象验证库 Spected
- 授权协议: MIT
- 开发语言: JavaScript
- 操作系统: 跨平台
- 软件首页: https://github.com/25th-floor/spected
- 软件文档: https://github.com/25th-floor/spected
- 官方下载: https://github.com/25th-floor/spected
软件介绍
Spected 是一个 JavaScript 编写的验证库,用于根据自定义的验证规则验证对象。它使你可以完全自由地使用验证规则,并且可以用于表单输入,深度嵌套的对象或客户端和服务器端的任何其他数据结构。
Basic Example
import { compose, curry, head, isEmpty, length, not, prop, } from 'ramda' import spected from 'spected' // predicates const notEmpty = compose(not, isEmpty) const hasCapitalLetter = a => /[A-Z]/.test(a) const isGreaterThan = curry((len, a) => (a > len)) const isLengthGreaterThan = len => compose(isGreaterThan(len), prop('length')) // error messages const notEmptyMsg = field => `${field} should not be empty.` const minimumMsg = (field, len) => `Minimum ${field} length of ${len} is required.` const capitalLetterMag = field => `${field} should contain at least one uppercase letter.` // rules const nameValidationRule = [[notEmpty, notEmptyMsg('Name')]] const randomValidationRule = [ [isLengthGreaterThan(2), minimumMsg('Random', 3)], [hasCapitalLetter, capitalLetterMag('Random')], ] const validationRules = { name: nameValidationRule, random: randomValidationRule, } spected(validationRules, {name: 'foo', random: 'Abcd'}) // {name: true, random: true}
C语言程序设计现代方法
K. N. King / 人民邮电出版社 / 2007-11 / 55.00元
《C语言程序设计现代方法》最主要的一个目的就是通过一种“现代方法”来介绍C语言,实现客观评价C语言、强调标准化C语言、强调软件工程、不再强调“手工优化”、强调与c++语言的兼容性的目标。《C语言程序设计现代方法》分为C语言的基础特性。C语言的高级特性、C语言标准库和参考资料4个部分。每章都有“问与答”小节,给出一系列与本章内容相关的问题及其答案,此外还包含适量的习题。一起来看看 《C语言程序设计现代方法》 这本书的介绍吧!