Skip to content

Add array field #88

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

Closed
wants to merge 13 commits into from
Closed

Conversation

bertramakers
Copy link
Contributor

This implements the array field discussed in #87 .

@tobyzerner a couple of things to keep in mind:

  • Array and List are reserved keywords in PHP and cannot be used as class names. I've temporarily used ArrayField as class name. Other possibilities are ArrayList, Arr (like Str), ... but I'm not a big fan of those either. I'll leave it up to you to decide on this.
  • I've only handled the validation. If you think the class should also define some other default methods like serialize(), deserialize(), etc let me know how you think they should behave. For my own use case the validation() was enough (at first glance).
  • The JSON pointer in errors regarding the items schema is now always the JSON pointer of the array property, while it should ideally be suffixed with /0, /1, ... (depending on the position of the item that is invalid). I didn't see a quick way to implement this, I think you may need to investigate this and adapt the error handling to deal with this.
  • As discussed the field injected into items() now also still requires a name. In the tests and my own app I've just used an empty string for now.

@tobyzerner
Copy link
Owner

This has been merged in e1c6901

@tobyzerner tobyzerner closed this Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants