Rename validator `with =` to `predicate = `
greyblake opened this issue · comments
Context
Currently it's possible to use for validation a custom function that returns either true
or false
. This function or closure is specified with with =
attribute.
In this issue we want it to rename to predicate =
Motivation
- It's natural to call predicate things that return
bool
- It will enable us to introduce custom
with =
function, which instead ofbool
will return any variant of error, so users may have more control the validation logic.
Specs
- Rename validation rule for all type families (integer, float, string) from
with
topredicate
- Do not rename
with =
sanitizer - Adjust the tests correspondingly (to run all suite
make test
) - Handle
with =
validation attribute by returning an error, saying that it's renamed intopredicate =
. Add an ui test for this. - Add a note about breaking change in CHANGELOG.md
Acceptance Criteria
- The following compiles
#[nutype(validate(predicate = |x| x % 2 == 0))]
pub struct Even(u32);
- The following fails ,saying that
with =
was renamed topredicate =
#[nutype(validate(with = |x| x % 2 == 0))]
pub struct Even(u32);
Addressed in #76