-
Notifications
You must be signed in to change notification settings - Fork 2
W-10974844 - Changes in mandatory array validation #515
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
Conversation
Git2Gus App is installed but the |
} | ||
|
||
private def parseMandatory: Option[ParsedEntry] = map.key("mandatory") match { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be done with a .map
method (?)
} | ||
|
||
private def parseMinItems: Option[ParsedEntry] = map.key("minItems") match { | ||
case Some(entry) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be done with a .map
method (?)
Annotations(entry)) | ||
} | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be able to see the cases better you could:
- extract each case into its own method. In that way, I can easily see all the cases with a method which in its name, clearly describes the functionality
- I wouldn't make each
if
clause be able to "interact" with the other clauses. Each case should be self-contained to be easier to explore and understand.
propertyMapping.mandatory().option() match { | ||
case Some(mandatory) => | ||
val mandatoryPos = fieldPos(propertyMapping, PropertyMappingModel.Mandatory) | ||
propertyMapping.minCount().option() match { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"mandatory" emitters could be extracted out of pattern matching as they are always plugged in.
"http://www.w3.org/ns/shacl#resultPath": { | ||
"@id": "http://a.ml/vocabularies/data#arrayProperty" | ||
}, | ||
"http://www.w3.org/ns/shacl#resultMessage": "Property 'arrayProperty' is mandatory", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error is weird, it doesn't have mandatory: true
in the instance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should throw a minItems
error
val mandatory = mandatoryValue == "true" | ||
// If minCount is 0 and it is mandatory, this comes from minItems = 0 + mandatory = true | ||
// I need to check only the presence of the property, empty arrays are valid | ||
if (minCount == 0 && mandatory) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all these comments could be replaced with variable names. For me it would be best not to have them because they interrupt my reading of the code but IDK, leave it as you deem useful.
No description provided.