10000 W-10974844 - Changes in mandatory array validation by looseale · Pull Request #515 · aml-org/amf-aml · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 3 commits into from
Apr 13, 2022

Conversation

looseale
Copy link
Contributor

No description provided.

@uip-robot-zz
Copy link

Git2Gus App is installed but the .git2gus/config.json doesn't exist.

}

private def parseMandatory: Option[ParsedEntry] = map.key("mandatory") match {
Copy link
Contributor

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) =>
Copy link
Contributor

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))
}
)

Copy link
Contributor

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 {
Copy link
Contributor

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",
Copy link
Contributor

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

Copy link
Contributor

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)
Copy link
Contributor

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.

@looseale looseale requested a review from tomsfernandez April 13, 2022 14:34
@looseale looseale merged commit fc38eb3 into develop Apr 13, 2022
@looseale looseale deleted the W-10974844-min-items branch April 13, 2022 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0