Skip to content

Instantly share code, notes, and snippets.

@venkatd venkatd/dry-validation-example.rb Secret
Last active Jan 24, 2016

Embed
What would you like to do?
class NodeArraySchema < Dry::Validation::Schema
array_of? NodeSchema
end
class NodeSchema < Dry::Validation::Schema
key(:path) { |path| path.filled? }
key(:attributes) { |attributes| attributes.hash? }
key(:relationships) do |relationships|
relationships.array_of? RelationshipSchema
end
end
class RelationshipSchema < Dry::Validation::Schema
key(:from) { |from| from.str? && from.filled? }
key(:to) { |to| to.str? && to.filled? }
key(:name) { |name| to.str? && to.filled? }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.