Skip to content

Instantly share code, notes, and snippets.

@sled
Last active April 13, 2016 21:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sled/a75cc293b2767c35f7c6bca9763877a2 to your computer and use it in GitHub Desktop.
Save sled/a75cc293b2767c35f7c6bca9763877a2 to your computer and use it in GitHub Desktop.
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