5 ms·
This reminds me of SQL's constraints, or pydantic's custom types and validators, which can validate that a value should be an int, and between 0-999, and not ex
by xarope 1y ago
This reminds me of SQL's constraints, or pydantic's custom types and validators, which can validate that a value should be an int, and between 0-999, and not exceed, e.g. -1 or 1000.
pydantic is a library for python, but I'm not aware of anything similar in rust or golang that can do this yet? (i.e. not just schema validation, but value range validation too)
- jayong93 1y ago[dead]
- kstrauser 1y agoThe semantics are a little different in that you have to explicitly call .validate(), but Rust's "validator" crate[0] feels a lot like Pydantic to me. [0]https://docs.rs/validator/latest/validator/ https://docs.rs/validator/latest/validator/
- xarope 1y agoI'm aware of this as well as go(lang)'s https://github.com/go-playground/validator https://github.com/go-playground/validator, so you are right, I'm wondering about a more implicit validator like what Pydantic does when a value is assigned, versus an explicit call to validate().