Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@venkatd
Last active January 24, 2016 17:58
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 venkatd/f010b7eba7ca410b85b8 to your computer and use it in GitHub Desktop.
Save venkatd/f010b7eba7ca410b85b8 to your computer and use it in GitHub Desktop.
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