Clause
(0.0.22)Introduction
Concepts
API
- clausejs.compose
- clausejs.utils
- clausejs.preds
- clausejs.namespace
- clausejs.types
Clause
(To contribute to API notes & examples, make a pull request to annotation source files here.)
Introduction
Refer to README file for basic intro.What is Conformation?
To put it plainly, as a developer you expect your data to be of certain "shape".
You define the shape of the data with clauses.
To "conform" your data with your clauses is to shape it in a way that is better organized, making it easier for your code to consume.
[TODO: more write-up]
Regex-like Operations on Iterables
Both array and string are treated as iterables in Clause, which means both types can be the subject of regex-like operations.
For example, both of the following clause definitions are valid:
var ArrayClause = C.cat('foos', C.oneOrMore(C.equal('foo')),
'bars', C.oneOrMore(C.equal('bar')));
C.conform(ArrayClause, ['foo', 'foo', 'foo', 'bar', 'bar']);
// returns { foos: ['foo', 'foo', 'foo'], bars: ['bar', 'bar'] };
var StrClause = C.cat('foos', C.oneOrMore(C.sEqual('foo')),
'bars', C.oneOrMore(C.sEqual('bar')));
C.conform(StrClause, 'foofoofoobarbar');
// returns { foos: 'foofoofoo', bars: 'barbarbar' };
Notice that in the first clause, we use C.equals() to treat the string as a single entity, whereas in the second, we use C.sEqual() to suggest that each character in the string is part of a collection that we run regex ops on.
API
Work in progress.
Below is a set of auto-generated API reference by
clausejs-docgen based on clause declarations and their corrosponding annotations.
Should satisfy all of the following expression:
Should be an ordered list of the following:
1st
<expressions>
Should be one of the following:
Should be one of the following:
Should be an ordered list of the following:
1st
<name>
2nd
<comment>
3rd
<expr>
Should be an ordered list of the following:
1st
<name>
2nd
<comment>
3rd
<expr>
2nd
<options>
Should satisfy all of the following expression:
Should satisfy all of the following expression:
Should be an ordered list of the following:
1st
<expressions>
Should be one of the following:
Should be one of the following:
Should be an ordered list of the following:
1st
<name>
2nd
<comment>
3rd
<expr>
Should be an ordered list of the following:
1st
<name>
2nd
<comment>
3rd
<expr>
2nd
<options>
Should satisfy all of the following expression:
Should be an ordered list of the following:
1st
<expr>
2nd
<opts>
Should be an ordered list of the following:
1st
<expr>
2nd
<opts>
Should be an ordered list of the following:
1st
<expr>
2nd
<opts>
Should be an ordered list of the following:
1st
<expr>
2nd
<opts>
Should be an ordered list of the following:
1st
<keyExpression>
2nd
<valExpression>
Should be an ordered list of the following:
1st
<shapeArgs>
Should be an ordered list of the following:
Should be an ordered list of the following:
1st
<fclauseFields>
Should be an ordered list of the following:
Should be an ordered list of the following:
Should be an ordered list of the following:
1st
<expression>
2nd
<valueToCheck>
Should be an ordered list of the following:
1st
<expression>
2nd
<valueToConform>
Should be one of the following:
Should be an ordered list of the following:
1st
<getFn>
Should be an ordered list of the following:
Should be an ordered list of the following:
1st
<predicateToNegate>
Should be an ordered list of the following:
1st
<x>
Should be an ordered list of the following:
1st
<x>
Should be an ordered list of the following:
1st
<x>
Should be an ordered list of the following:
1st
<x>
Should be an ordered list of the following:
1st
<x>
Should be an ordered list of the following:
1st
<x>
Should be an ordered list of the following:
1st
<x>
Should be an ordered list of the following:
1st
<x>
Should be an ordered list of the following:
1st
<x>
Should be an ordered list of the following:
1st
<x>
Should be an ordered list of the following:
1st
<x>
Should be an ordered list of the following:
1st
<x>
Should be an ordered list of the following:
1st
<x>
Should be an ordered list of the following:
1st
<x>
Should be an ordered list of the following:
1st
<valueOptions>
Should be an ordered list of the following:
1st
<x>
Should be an ordered list of the following:
1st
<valueToCompareWith>
Should be an ordered list of the following:
1st
<x>
Should be an ordered list of the following:
1st
<instanceType>
Should be an ordered list of the following:
1st
<x>
Should be an ordered list of the following:
1st
<nsPath>
2nd
<expression>
Should be an ordered list of the following:
1st
<nsPath>
Should be an ordered list of the following:
1st
<source>
Should be one of the following:
2nd
<metaObj>
Should be one of the following:
Should satisfy all of the following expression:
Should be one of the following:
C()
function
C(nsPath, expression)
C(nsPath)
clausejs.compose/
cat()
function
or()
function
zeroOrMore()
function
zeroOrMore(expr, opts)
oneOrMore()
function
oneOrMore(expr, opts)
zeroOrOne()
function
zeroOrOne(expr, opts)
and()
function
collOf()
function
collOf(expr, opts)
mapOf()
function
mapOf(keyExpression, valExpression)
shape()
function
shape(shapeArgs)
any()
function
wall()
function
wall(Expression)
fclause()
function
fclause(fclauseFields)
nullable()
function
nullable(Expression)
undefinable()
function
undefinable(Expression)
clausejs.utils/
enforce()
function
enforce(expression, valueToCheck)
conform()
function
conform(expression, valueToConform)
delayed()
function
delayed(getFn)
C.describe()
function
C.describe()
clausejs.preds/
not()
function
not(predicateToNegate)
(x)
isObj()
function
isObj(x)
isStr()
function
isStr(x)
isArray()
function
isArray(x)
isDate()
function
isDate(x)
isNull()
function
isNull(x)
isUndefined()
function
isUndefined(x)
notEmpty()
function
notEmpty(x)
isBool()
function
isBool(x)
isFn()
function
isFn(x)
isNum()
function
isNum(x)
isInt()
function
isInt(x)
isNatInt()
function
isNatInt(x)
isUuid()
function
isUuid(x)
oneOf()
function
oneOf(valueOptions)
(x)
equals()
function
equals(valueToCompareWith)
(x)
instanceOf()
function
instanceOf(instanceType)
(x)
clausejs.namespace/
set()
function
set(nsPath, expression)
get()
function
get(nsPath)
meta()
function
meta(source, metaObj)
clausejs.types/
Expression
or
Clause
predicate
FClause
and
Predicate
predicate
DelayedClause
predicate
ClauseReference
predicate
Problem
predicate
NamespaceObj
shape
NamespacePath
predicate
Primitive
or