Closed radar closed 5 years ago
If you need uuid?
I would actually accept a PR that adds it (see https://github.com/dry-rb/dry-logic/issues/43)
In general, custom predicates will be discouraged in dry-validation 1.0.0 because schemas should be used for simple checks and rule
should be used for other, for domain-specific validations.
Thanks @solnic.
So just to double check: we should definitely be using rules here instead of new predicates?
I’ve looked at #43 and the uuid-tools gem and the gem’s code is scary byte stuff with Ruby that I don’t want to tinker with. Braver souls might prevail.
So just to double check: we should definitely be using rules here instead of new predicates?
For a type-check like uuid?
I would say a predicate makes sense but ie for checking if the value is unique (in the db sense) it should be a rule.
I’ve looked at #43 and the uuid-tools gem and the gem’s code is scary byte stuff with Ruby that I don’t want to tinker with. Braver souls might prevail.
Yeah UUIDs are actually more complex than some people may think 😄 Maybe we could add a simple regex-based check to cover the common case.
I'm currently attempting to create custom predicates by writing this code:
However, this code raises an exception:
What am I doing wrong here?
I couldn't find any documentation for this in dry-validation, or dry-logic.
Gemfile
Gemfile.lock