自定义规则对象验证库 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++数据结构与算法
[美]乔兹德克(Adam Drozdek) / 徐丹、吴伟敏 / 清华大学出版社 / 2014-10-1 / 63.00元
本书全面系统地介绍了数据结构,并以C++语言实现相关的算法。书中主要强调了数据结构和算法之间的联系,使用面向对象的方法介绍数据结构,其内容包括算法的复杂度分析、链表、栈、队列、递归、二叉树、图、排序和散列。书中还清晰地阐述了同类教材中较少提到的内存管理、数据压缩和字符串匹配等主题。书中包含大量的示例分析和图形,便于读者进一步理解和巩固所学的知识。一起来看看 《C++数据结构与算法》 这本书的介绍吧!
