Skip to content

Instantly share code, notes, and snippets.

@fnordfish
Last active August 4, 2017 07:20
Show Gist options
  • Save fnordfish/2f65cb01865b6d12890cb743832e2b9b to your computer and use it in GitHub Desktop.
Save fnordfish/2f65cb01865b6d12890cb743832e2b9b to your computer and use it in GitHub Desktop.
Trailblazer Wishlist: Contract with dry-v Schema reusage
class MyBaseSchema < Dry::Validation::Schema
configure do
# my custom predicates, messages_file, etc.
end
end
TestSchema = Dry::Validation.Form(MyBaseSchema) do
required(:foo).filled
end
class TestContract < Reform::Form
include Dry
property :foo
# I'd like to do something like this:
validation :default, schema: TestSchema
# Or this:
validation :default, base_schema: MyBaseSchema do
required(:foo).filled
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment