Skip to content

v0.7.0

Choose a tag to compare

@vkiryakov vkiryakov released this 17 Oct 10:24
· 21 commits to dev since this release
ce5093b

Zefir 0.7.0 adds outside names and transforms to zefir-validator.

validator

The entry of a field in field_rules can now carry, in this order, an outside name, transforms and rules:

pub const field_rules = .{
    .user_name = .{ v.rename("userName"), v.trim, v.notBlank, v.maxLength(100) },
    .email = .{ v.trim, v.toLower, v.email },
    .tags = v.each(.{ v.trim, v.notBlank }),
};
  • v.rename("userName"): the field's outside name. Violation paths use it (userName, speakers[1].displayName). v.nameOf and v.fieldNamed give the names to a codec of your own; no zefir module reads or writes JSON by them yet.
  • Transforms: v.trim, v.trimStart, v.trimEnd, v.toLower, v.toUpper (ASCII letters only) and v.transformWith(f), also inside v.each. v.transform(arena, &value) runs them before v.check or v.checkAll; v.TransformError(T) is its exact error set.
  • Existing field_rules work as before. A field whose Zig name has ., [ or ] is now accepted when v.rename gives it a clean outside name.

See the validator guide.

rpc-nats

zig fetch --save git+https://github.com/vkiryakov/zefir#v0.7.0