Repository navigation
v0.7.0
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.nameOfandv.fieldNamedgive 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) andv.transformWith(f), also insidev.each.v.transform(arena, &value)runs them beforev.checkorv.checkAll;v.TransformError(T)is its exact error set. - Existing
field_ruleswork as before. A field whose Zig name has.,[or]is now accepted whenv.renamegives it a clean outside name.
See the validator guide.
rpc-nats
- Writing a transport: how rpc-nats is built, as a guide to writing a transport of your own.
zig fetch --save git+https://github.com/vkiryakov/zefir#v0.7.0