←back to thread

611 points LorenDB | 1 comments | | HN request time: 0s | source
Show context
xarope ◴[] No.43911947[source]
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)

replies(2): >>43912721 #>>43918793 #
kstrauser ◴[] No.43918793[source]
The 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/

replies(1): >>43933655 #
1. xarope ◴[] No.43933655[source]
I'm aware of this as well as go(lang)'s 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().