Skip to content
This repository has been archived by the owner on Feb 17, 2023. It is now read-only.

CompositeSchema should allow to pass options to composed schema. #1

Open
nicolasdespres opened this issue May 21, 2013 · 0 comments
Open

Comments

@nicolasdespres
Copy link
Owner

Consider the following CompositeSchema:

module Respect
  class PointSchema < CompositeSchema
    def schema_definition
      HashSchema.define do |s|
        s.float "x"
        s.float "y"
      end
    end
  end
end

when using it like that:

HashSchema.define do |s|
  s.point :center
end

The user should be able to pass options to the underlying x and y properties like that:

HashSchema.define do |s|
  s.point :center, x: { greater_than: 4 }, y: { in: 42.5..51.5 }
end

Recursive composite schema must work too. Consider:

HashSchema.define do |s|
  s.circle "area", radius: { greater_than: 10.0 }, center: { x: greater_than: 5.0 }
end

For array we could use the index for key (items and extra items) and :all (item).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant