[dry-validation] What's your use case?

I’m using dry-validation and I’m really happy about it: I can remove validation from my model and a validation based on business actions (thanks to dry-transaction), and I like it.

However, I’m starting to thing if I should using it everywhere, or only on business actions such as CreateUser, SendEmailToPaidCustomer etc…

For example, if I have a ReimburseTimeTable, should dry-validation be responsible to check if it’s time to do the reimbursement?

As I see it, dry-validation and dry-schema can help you when you are trying to validate any data that comes from the current state of the world (being it a user input or the current time). If your validations are only related to the type of the data (is it a string? an integer?) or its structure (does this hash have a foo: key), then you only need dry-schema. If you have to validate business rules, then go with dry-validation.

So, for your concrete example, ReimburseTimeTable, it depends on the source of the data it consumes. If it comes from the outside, you can use dry-validation. If your data is internal but you still want some type safety, you can still use something like dry-types.

1 Like