-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
The unevaluatedItems lesson needs work #61
Comments
@jdesrosiers @JeelRajodiya May I work on this issue? Please give me your suggestions, as I need your help in resolving it. const code: any = {
$defs: {},
type: "object",
properties: {
name: {
type: "string",
},
age: {
type: "integer",
},
skills: {
type: "array",
},
},
};
const solution = structuredClone(code);
// Define the $defs for the tuple
solution.$defs = {
tuple: {
type: "array",
prefixItems: [
{ enum: ["HTML", "CSS", "JavaScript"] },
{ enum: ["HTML", "CSS", "JavaScript"] },
{ enum: ["HTML", "CSS", "JavaScript"] }
],
},
};
// Update the 'skills' property to use the tuple and unevaluatedItems
solution.properties.skills = {
type: "array",
$ref: "#/$defs/tuple",
prefixItems: [
true,
true,
{ type: "string" }
],
unevaluatedItems: true
};
const testCases = [
{
input: {
name: "John Doe",
age: 30,
skills: ["HTML", "CSS", "JavaScript", "TypeScript"],
},
expected: true,
},
{
input: {
name: "John Doe",
age: 30,
skills: ["JavaScript", "CSS", "HTML", "TypeScript"],
},
expected: true,
},
{
input: {
name: "John Doe",
age: 30,
skills: ["JavaScript", "HTML", "CSS", "TypeScript"],
},
expected: true,
},
{
input: {
name: "John Doe",
age: 30,
skills: ["HTML", "CSS", "JavaScript", 123],
},
expected: true,
},
{
input: {
name: "John Doe",
age: 30,
skills: ["HTML", "CSS", "JavaScript", "TypeScript", "React"],
},
expected: true,
},
{
input: {
name: "John Doe",
age: 30,
skills: ["React", "Java", "Vue.js"],
},
expected: false,
},
{
input: {
name: "John Doe",
age: 30,
skills: ["HTML", "JavaScript", "TypeScript", "React", "Vue"],
},
expected: false,
},
];
module.exports = {
code,
solution,
testCases,
}; and this solution passed all test cases {
"$defs": {
"tuple": {
"type": "array",
"prefixItems": [
{
"enum": [
"HTML",
"CSS",
"JavaScript"
]
},
{
"enum": [
"HTML",
"CSS",
"JavaScript"
]
},
{
"enum": [
"HTML",
"CSS",
"JavaScript"
]
}
]
}
},
"type": "object",
"properties": {
"name": {
"type": "string"
},
"age": {
"type": "integer"
},
"skills": {
"type": "array",
"$ref": "#/$defs/tuple",
"prefixItems": [
true,
true,
{
"type": "string"
}
],
"unevaluatedItems": true
}
}
} |
I'm not a maintainer of this repo, so I can't give you the go ahead to work on this, but I can provide feedback on the proposal. This proposed schema doesn't do anything and isn't an example of a use-case for
I wouldn't try to iterate off of the original schema because it doesn't make sense to start with. Using
The only one that's going to be easy to come up with a realistic example is going the be the first case. The only realistic case I've ever seen for the second case is modeling variatic functions. For the third case, I'm not sure there is an example of using Good luck coming up with your examples. I'm here to help verify you're on the right track. |
as per the discussion the slack, we have removed the lesson. If someone wish to improve the lesson, they can refer here to the previous state of the repo and suggest changes accordingly. |
Hi @JeelRajodiya yes I am interested |
@techmannih I hope you have read the slack discussion I mentioned above and this message. If you are confident in resolving the issue. feel free to open a PR directly. |
The
unevaluatedItems
lesson is a lesson foritems
, notunevaluatedItems
. While you can useunevaluatedItems
in place ofitems
and get the same result, this lesson does nothing to show an actual use case for the keyword. Notice that this passes the lesson.A lesson on
unevaluatedItems
should include extending and/or closing a tuple using an applicator of some kind. Here's an example of adding an item to the tuple and closing it to further extension.The text was updated successfully, but these errors were encountered: