stevedlawrence commented on a change in pull request #431:
URL: https://github.com/apache/incubator-daffodil/pull/431#discussion_r504136376
##########
File path: daffodil-cli/src/main/scala/org/apache/daffodil/Main.scala
##########
@@ -234,7 +236,11 @@ class CLIConf(arguments: Array[String]) extends
scallop.ScallopConf(arguments)
case "on" => ValidationMode.Full
case "limited" => ValidationMode.Limited
case "off" => ValidationMode.Off
- case _ => throw new Exception("Unrecognized ValidationMode %s. Must be
'on', 'limited' or 'off'.".format(s))
+ case Validator.MultiArgsPattern(str, args) if Validators.exists(str) =>
+ ValidationMode.Custom(str, args.split(",").map(_.split("=")).map(kv =>
Validator.Argument(kv.head, kv.last)))
+ case Validator.DefaultArgPattern(str, arg) if Validators.exists(str) =>
ValidationMode.Custom(str, Seq(Validator.Argument(arg)))
+ case Validator.NoArgsPattern(str) if Validators.exists(str) =>
ValidationMode.Custom(str, Seq.empty)
Review comment:
Are these patterns expected to be used via an API user? If not, they
should probably only be defined in this Main.scala if the format is specific to
the CLI usage.
##########
File path:
daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/DataProcessor.scala
##########
@@ -702,10 +706,22 @@ class ParseResult(dp: DataProcessor, override val
resultState: PState)
*/
def validateResult(bytes: Array[Byte]): Unit = {
Assert.usage(resultState.processorStatus eq Success)
- val schemaURIStrings =
resultState.infoset.asInstanceOf[InfosetElement].runtimeData.schemaURIStringsForFullValidation
+
+ val (v, args) = dp.validationMode match {
+ case ValidationMode.Custom(name, args) =>
+ Validators.find(name).getOrElse(
+ Assert.abort(s"Validator '$name' not found")
Review comment:
Can we move much of this find logic to when a user calls
withValidationMode? That way we can detect if a validator exists and has the
right args before we try to actually parse things? It would be nice if all the
logic here was just the below ``v.validateXML(...)``.
This feels like perhaps it might lead nicely into
[DAFFODIL-1749](https://issues.apache.org/jira/browse/DAFFODIL-1749). Or
perhaps that should just be done separately, since that's already how our logic
behaves right now. Just something to think about as we add this new API to make
sure that is possible.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]