Changelog
v2.0
- Switched to semver. The new release version is 2.0.
- Unified approach to types handling.
- "Base rules" renamed to "Common rules".
- "Filter rules" renamed to "Modifiers". They do not validate anything, they just modify data.
- "Helper rules" renamed to "Metarules", as these rules are for describing other rules.
- Added common rule
any_object. - Added string rule
string. - Added string rule
eq. - Added metarule
variable_object. - Added metarule
or. - Added modifier
default. - Added more edge cases to the test suite.
- Marked the
likerule as experimental.
v0.4
- Added special rules
urlandiso_date. - Added filter rules
removeandleave_only. - Added support for the
iflag to thelikerule. - Introduced a new syntax for the
one_ofandlist_ofrules, see below. - Rules aliasing, with custom errors.
v0.3
v0.2
- Added the
not_empty_listrule with test cases.
Syntax changes for one_of and list_of rules
The old syntax { one_of: [['val1', 'val2']] } was hard to remember for many people. The idea was that the list of allowed values is passed as a single array argument: { one_of: [['val1', 'val2']] } becomes one_of(['val1', 'val2']). But that is not obvious for users.
So a new syntax was introduced: { one_of: ['val1', 'val2'] } becomes one_of('val1', 'val2'). The problem is that you do not know how many arguments will be passed to one_of, and both syntaxes must be supported for backward compatibility (the test suite covers both). It was decided that the one_of and list_of rules handle both syntaxes by themselves.
Documentation TODO
- Describe the internals with a detailed step-by-step example.
- Write a developers guide.