Last active
April 13, 2016 21:23
-
-
Save sled/a75cc293b2767c35f7c6bca9763877a2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 User < Dry::Types::Struct | |
attribute :name, Types::String | |
attribute :birth_day, Types::Date | |
end | |
UserSchema = Dry::Validation.Schema do | |
key(:name).required | |
key(:birth_date).required(:date?) | |
end | |
User.new( | |
UserSchema.with(input_processor: :json) | |
.call(name: "Joe", birth_date: "2012-04-23T18:25:43.511Z") | |
.output | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment