Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a way of defining schemas for arrays as root nodes #22

Open
flash-gordon opened this issue Feb 6, 2019 · 8 comments
Open

Provide a way of defining schemas for arrays as root nodes #22

flash-gordon opened this issue Feb 6, 2019 · 8 comments
Labels
Milestone

Comments

@flash-gordon
Copy link
Member

@flash-gordon flash-gordon commented Feb 6, 2019

As an example

Dry::Schema.JSON do
  each do
    schema do
      required(:name).filled(:str?)
      required(:age).filled(:int?)
    end
  end
end
@Morozzzko
Copy link
Member

@Morozzzko Morozzzko commented Jun 4, 2019

@solnic
Copy link
Member

@solnic solnic commented Jun 4, 2019

I've been thinking about it, we could give this a shot, we have better APIs to build this feature now. The only difference would be to use array instead of each.

@dsennerlov
Copy link

@dsennerlov dsennerlov commented Sep 2, 2019

Also needs to support the simple case of

[
	"I'm a string",
	"I'm another string"
]

@CesarOliveira
Copy link

@CesarOliveira CesarOliveira commented Jul 27, 2020

There is a way to workaround this until have a final solution?

@solnic
Copy link
Member

@solnic solnic commented Jul 28, 2020

@CesarOliveira you can define a schema for an array item and have a wrapper that applies it to each item and then merge results into one.

@CesarOliveira
Copy link

@CesarOliveira CesarOliveira commented Jul 28, 2020

hi @solnic I thought something like that, put a verification inside the match_schema.rb if is a collection and call the schema for each item, but I thought maybe was something similar done in the gem, thanks for the answer and congrats in the gem as well

@volkanunsal
Copy link

@volkanunsal volkanunsal commented Mar 27, 2021

Any update on this feature?

@solnic
Copy link
Member

@solnic solnic commented Mar 30, 2021

@volkanunsal not yet, still scheduled for 2.0.0 though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

6 participants