-
Notifications
You must be signed in to change notification settings - Fork 6
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
Passing an empty list as parmeter #47
Comments
Thanks for the suggestion! |
Marking a parameter as required actually means that there should be at least one value. Due to the semantics of JSON-LD and RDF, I presume that in this case, you probably want to make the parameter optional. |
That would mean there is no semantic difference between an empty list and no list at all ... |
The thing you see in the Components.js config is actually not a list semantically speaking. In JSON-LD the brackets are used to create multiple triples with the same predicate. To have a list you need the @list keyword. Components.js is just nice enough to interpret all those triples as a list of values instead of separate values (I'm guessing because the @list syntax would make it a lot uglier), even though semantically that's not really a list. The disadvantage of that technique though is indeed that if there are no values (which is identical to writing |
One solution would be to introduce the following behaviour: Concretely, this would mean that passing This is a minor change in semantics for Components.js (that would call for a major update), as non-unique+required fields would require at least one value before. Since this check could be considered a bit arbitrary for arrays, it makes sense to apply this change in semantics. If the "if the array contains at least one value" check would be necessary, then we could add this via a new @woutermont @joachimvh Would such a change make sense to you? |
The only time unique is false is when the input parameter is an array right? In that case this sounds like a reasonable solution. Only disadvantage is that you lose the error message in case you forget to define the parameter. I've never had a need yet for empty arrays but since it's currently impossible to define them I think this solution is better than the current situation. |
While I think it's semantically a bit strange, it would definitely be more workable than the current situation. |
Actually, after thinking about it a bit more, I think the following solution might be cleaner: For a given config: {
"@type": "MyClass",
"param1": []
} The generator would set the JSON-LD container type to Next, Components.js would require a small change, as it would now also need to support such RDF lists as input to parameters. I don't foresee major difficulties for this. The advantage of this approach would be that Components.js will still throw an error if you don't define @joachimvh @woutermont Any thoughts? |
Ah yea, that's definitely better. I just assumed that one wasn't an option :D |
Discovered in CommunitySolidServer/CommunitySolidServer#792 This was introduced by #47.
Issue type:
Description:
When a constructor requires a (mandatory) list as argument, currently the instantiattion fails if the list passed in the configuration is empty (
"ClassName:_listParam": []
). Is there a workaround for this behavior?The text was updated successfully, but these errors were encountered: