Skip to content

prefixItems should not allow arrays of variable length #193

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

Open
markoutso opened this issue Feb 17, 2022 · 10 comments
Open

prefixItems should not allow arrays of variable length #193

markoutso opened this issue Feb 17, 2022 · 10 comments
Labels
📝 Documentation Indicates improvements or additions to documentation. 💬 Question Further information is requested Status: Do not close This is a long term issue with dependant issues. This label prevent it to be closed automatically.

Comments

@markoutso
Copy link

The documentation states that the keyword prefixItems is used for tuple validation.
In the realm of programming and mathematics a tuple is something that has specific length.
Quoting Wikipedia:

In computer science, tuples come in many forms. Most typed functional programming languages implement tuples directly as product types,[1] tightly associated with algebraic data types, pattern matching, and destructuring assignment.[2] Many programming languages offer an alternative to tuples, known as record types, featuring unordered elements accessed by label.[3] A few programming languages combine ordered tuple product types and unordered record types into a single construct, as in C structs and Haskell records. Relational databases may formally identify their rows (records) as tuples.

The json schema specification should follow common conventions or choose a better description for this validation.

In my opinion referring to arrays with variable as length as tuples is something that goes against the definition of the tuple and creates unnecessary confusion.

I would suggest that prefixItems stays as it is and it requires that all sub schemas validate the array elements in order. No more elements or should be allowed.

@gregsdennis
Copy link
Member

Tuples are but one application of this keyword. I agree that it's odd they are highlighted as the reasoning behind the keyword, but it's current function does have merit.

Perhaps we can improve this section by focusing on what it does rather than try to illustrate one use case.

@jdesrosiers what do you think of moving the tuples language out of the spec and into the UJS content?

@Relequestual
Copy link
Member

The documentation states...

@markoutso @gregsdennis I don't see "tuple" in this repo at all. Which documentation do you mean specifically? (Likely need to migrate the issue.)

I usually describe it as "tuple form" validation as opposed to tuple validation.

@markoutso
Copy link
Author

Thanks everyone for looking at this!
@Relequestual I double checked and you are right. This belongs to the Understanding Json Schema book.

@Relequestual Relequestual transferred this issue from json-schema-org/json-schema-spec Feb 18, 2022
@jdesrosiers
Copy link
Member

I agree "tuple" isn't a perfect description, but I think it's more helpful than misleading. prefixItems (or previously array-form-items) is primarily useful for describing a tuple. I think the way it's written makes it sound like, if you're using this keyword then you're describing a tuple, which isn't always true. I think I'd like the example to be a tuple and call it a tuple, but make it more clear that you can describe things that are not quite tuples with this keyword as well.

In any case, I have another three months before I'll have a chance to work on this. So, don't wait on me if anyone wants to put up a PR.

@gregsdennis
Copy link
Member

is primarily useful for describing a tuple

I think this is an incorrect assumption, and probably the basis of this confusion.

@benjagm benjagm transferred this issue from json-schema-org/understanding-json-schema Nov 2, 2023
@Julian
Copy link
Member

Julian commented Nov 2, 2023

I've also previously expressed I think this language isn't really standard and is particularly confusing in languages which has a type called tuple. So +1 from me at least for avoiding it, I wouldn't change any keywords at all personally, but I definitely do not use the word "tuple" in the context of JSON Schema or JSON more broadly myself.

@benjagm
Copy link
Collaborator

benjagm commented Nov 23, 2023

Hi all. What could be the best term we should use to replace Tuple in our docs?

@benjagm benjagm added 📝 Documentation Indicates improvements or additions to documentation. 💬 Question Further information is requested labels Nov 23, 2023
@benjagm benjagm moved this to Todo in JSON Schema Docs Nov 23, 2023
@benjagm benjagm added the agenda To be added to the next Community Meeting label Feb 20, 2024
@gregsdennis
Copy link
Member

gregsdennis commented Feb 26, 2024

@benjagm benjagm added Status: On Hold Similar to blocked, but is assigned to someone. 💬 Question Further information is requested and removed 💬 Question Further information is requested agenda To be added to the next Community Meeting Status: On Hold Similar to blocked, but is assigned to someone. labels Feb 26, 2024
@benjagm benjagm moved this from Todo to On Hold in JSON Schema Docs Mar 2, 2024
Copy link

github-actions bot commented Jun 9, 2024

Hello! 👋

This issue has been automatically marked as stale due to inactivity 😴

It will be closed in 180 days if no further activity occurs. To keep it active, please add a comment with more details.

There can be many reasons why a specific issue has no activity. The most probable cause is a lack of time, not a lack of interest.

Let us figure out together how to push this issue forward. Connect with us through our slack channel : https://json-schema.org/slack

Thank you for your patience ❤️

@github-actions github-actions bot added the Status: Stale It's believed that this issue is no longer important to the requestor. label Jun 9, 2024
@benjagm benjagm added Status: Do not close This is a long term issue with dependant issues. This label prevent it to be closed automatically. and removed Status: Stale It's believed that this issue is no longer important to the requestor. labels Jun 9, 2024
@Vineet1101
Copy link

@benjagm can we use "list" instead of "tuple" coming from python background I agree that tuple can be confusing sometimes for me as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📝 Documentation Indicates improvements or additions to documentation. 💬 Question Further information is requested Status: Do not close This is a long term issue with dependant issues. This label prevent it to be closed automatically.
Projects
None yet
Development

No branches or pull requests

7 participants