Last active
August 4, 2017 07:20
-
-
Save fnordfish/2f65cb01865b6d12890cb743832e2b9b to your computer and use it in GitHub Desktop.
Trailblazer Wishlist: Contract with dry-v Schema reusage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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