Replies: 10 comments 4 replies
-
this would impact |
Beta Was this translation helpful? Give feedback.
-
The naming is one of a series of quirks that I don't think can be perfect... we have a few other properties where the name is a bit ambiguous, for example "minimum"... well, minimum what? (scalar value, item count, string length, sort order, ...?) Sometimes this could have been better thought through: When we were changing how "required" worked, that may have been a good opportunity to name it "requiredProperties" instead. But even in this case it might not matter (it only makes sense to think of properties as being required or not). However I don't think "present" would have been a better name. The naming scheme for validation keywords follows assertive language. A schema "requires" a property, it doesn't "present" a property. Likewise, there's other properties that could be confusing: "if minLength: 5 then ..." well hold up, this will evaluate true for all numbers and other non-string types! A better way to explain its behavior might be like this: "If the condition that the property 'foo' is required is valid, then ..." or "If the condition minLength: 5 validates, then ..." |
Beta Was this translation helpful? Give feedback.
-
I'd be extremely hesitant to start renaming keywords, since (as @awwright noted) there are several that could probably be better. Most of the keywords were chosen by people who left the project nearly a decade ago or longer, and most of the newer keywords were chosen to align with those. We have done a few renames:
Perhaps at some point if we need to do some sort of large-scale breaking change, a holistic rename could be consider. But more likely, it's better to push for |
Beta Was this translation helpful? Give feedback.
-
I would describe the real meaning behind this to be that a schema requires the presence of a property. It looks like you're using the verb form, 'to present a property' rather than an adjective, which isn't how I mean it (though that potential ambiguity may be a downside of the name).
I agree with this; I see the assertion being made to be that the property is present. Asserting a condition and requiring that condition seem synonymous to me. For |
Beta Was this translation helpful? Give feedback.
-
I object to the choice of "present" because it's such an overloaded word in english:
If we are in the mood to change the name of this keyword (and personally I am not), I think "mustExist" or "exists" would be clearer than "present". |
Beta Was this translation helpful? Give feedback.
-
I do agree. I also agree with all of the naming changes that have been made so far, the ones you've listed, the It may be the case that other keywords could be named better too. And it is always the case that I can take any idea I like and do my own vocabulary that nobody but me will use. That doesn't help improve the clarity of the core validation's |
Beta Was this translation helpful? Give feedback.
-
@karenetheridge I do think |
Beta Was this translation helpful? Give feedback.
-
The critically important difference here is that none of them were renamed just to rename them. The closest would be adding That is extremely important. We have never renamed a keyword just because we didn't like the name. No one will ever agree on what names are best. We all have keyword names that we think are unclear or just not ideal. I would strongly prefer not to debate different names because the question that needs to be answered first is "should we be renaming at all?", and I think the answer to that is an emphatic "no." |
Beta Was this translation helpful? Give feedback.
-
I broadened the discussion topic, because this is not the sort of thing that should be discussed piecemeal. When it comes to long-established keywords, it is important to set and meet clear expectations with users. We have not articulated a policy here (and I am not asserting one — such a policy would be the decision of the core team), but there is a de-facto policy that can be inferred.
I do not think that this discussion should hinge on any argument about The real question is, any such change would violate the above de-facto policy and expectations. Why would we want to do that? Not in terms of any one keyword, but in general? What are the costs of renaming?
I find both of these very concerning. What are the real-world problems that we can observe from not having renamed these?I am not aware of anything but personal preference here — I would like to see an actual example of measurable impact, or even anecdotal evidence beyond considering certain names sub-optimal or inconsistent. Those are nice theoretical issues, but what are the real effects? and why do they outweigh the above costs? |
Beta Was this translation helpful? Give feedback.
-
I agree with the general consensus here that renaming |
Beta Was this translation helpful? Give feedback.
-
I will recognize at the outset this is change would be a significant backwards incompatibility. I want to at least bring it for discussion.
I think the keyword "required" has a poor name for its purpose. All of the validation keywords express requirements of one sort or another.
required
should be named for what it is actually requiring - the presence of the indicated properties. I think "present" is the best keyword to express this. some variant of "properties present" might be an option too.The current name is okay for positively validating - saying a property is required does imply that its presence is the requirement. That case is natural enough to read and make intuitive sense. But we have all seen the confusion that results when using it in conditional or negated schemas.
"If property
foo
is required, then ..." is how that reads, but what it means is not very intuitive. "If propertyfoo
is present" is much more applicable, and reads more naturally fromif: {present: ["foo"]}
.Likewise,
not: {required: ["foo"]}
does not mean "propertyfoo
is not required". Multiple properties are worse:not: {required: ["foo", "bar"]}
reads like "neitherfoo
norbar
is required". Much improved,not: {present: ["foo", "bar"]}
does assert "propertiesfoo
andbar
are not present" or "must not be present".I think
required
made more sense back when it was a boolean keyword of a property schema, but would have been better renamed when it was put in its right place as a sibling ofproperties
. I think the namepresent
is a significant improvement - I'm interested to hear people's opinions.Of course, there are countless schemas which use
required
. This would be a widely impactful change, though not the biggest (e.g. smaller thanid
/$id
, I think). There are tools to convert schemas between spec versions, and this would be a trivial conversion to implement. Mayberequired
could live on for a while as a deprecated alias with the same function aspresent
(though I don't think the spec has ever done that before and that may be a whole other issue to address).I think in the long run, though this change would have some pain in its transition, it is worth the benefit of more clearly expressing the intent and meaning of the keyword in all the contexts where it is used.
Beta Was this translation helpful? Give feedback.
All reactions