I’m interested in your opinion. If validation-contracts are needed in a Hanami 2 app. Is it safe to create contracts like
module PaymentSlice
module Contracts
class PaymentContract < Dry::Validation::Contract
schema do
required(:amount).value(:integer)
# ...
end
end
end
end
or is it better to use include Hanami::Validations like
module PaymentSlice
module Contracts
class PaymentContract
include Hanami::Validations
validations do
required(:amount).value(:integer)
# ...
end
end
end
end
Yes it is. Hanami-validations is mostly a helper for validations at the params level but you have more control and more functionality if you use dry-validation standalone. We’re still exploring how exactly we want to structure validations in a hanami app and what exactly hanami-validations should do. Ideas are welcome btw!