是否有JavaScript的代码合同库? [英] Is there a code contract library for JavaScript?
问题描述
有许多 form验证库和jQuery插件.尽管我找不到用于验证函数参数的代码协定库.
There are lots of form validation libraries and jQuery plugins. Though I cannot find a code contract library, for validating function arguments.
例如,要在.NET中进行合同验证,您可以使用出色的条件库.我正在寻找类似的JavaScript.我能找到的最接近的是 Speks ,但它适用于Node.js,适合进行测试,而我需要将验证放入发布代码中.
As an example, to do contract validation in .NET, you could use the outstanding Conditions library. I'm looking for something similar for JavaScript. The closest I can find is Speks, but its for Node.js and is geared for testing, whereas I need to bake the validation into release code.
我需要的验证方法示例:检查null,空,isstring,isnumber,长度,min,max,value,小于,大于,之间,不等于,不小于,不大于等,
Examples of validation methods I need: checks for null, empty, isstring, isnumber, length, min, max, value, less than, greater than, between, not equal, not less than, not greater than, etc.
推荐答案
This is a runtime type contracts library which takes on some Haskell like syntax: http://code.google.com/p/ristretto-js.
这篇关于是否有JavaScript的代码合同库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!