-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: not-eq
assertion
#40
Comments
You can use the #let schema = z.string(min: 1) For more involved checks, you can simply create your own assertions these simply have to be dictionaries containing a condition and message callback, here's the #(
// return true if the assertion passed
condition: (self, it) => it.len() >= rhs,
// return a message to panic with
message: (self, it) => "Length must be at least " + str(rhs),
) |
Oh, that's great (and obvious in hindsight), thanks! Feel free to close the issue. |
There are a few |
For strings something like "not-empty" might be more useful. |
Pull request on this implements neq for lengths too, so not empty could be a length not equal to 0, which I think is similar enough to your request that I want to consider it already completed |
It would be useful to have an assertion that acts opposite to
eq
, e.g.,#let schema = z.string(assertions: (z.assert.not-eq(""),))
It's possible that it is already doable with the current functionality but I haven't found an obvious way for doing so.
The text was updated successfully, but these errors were encountered: