-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '2.2.0-dev' into email-support
- Loading branch information
Showing
4 changed files
with
39 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,7 @@ public class JsonSchemaValidator { | |
log.error("""Failed to load the meta schema: | ||
The used schema draft (${draft}) is not correct, please use \"https://json-schema.org/draft/2020-12/schema\" instead. | ||
- If you are a pipeline developer, check our migration guide for more information: https://nextflow-io.github.io/nf-schema/latest/migration_guide/ | ||
- If you are a pipeline user, pin the previous version of the plugin (1.1.3) to avoid this error: https://www.nextflow.io/docs/latest/plugins.html#using-plugins, i.e. set `plugins { | ||
- If you are a pipeline user, revert back to nf-validation to avoid this error: https://www.nextflow.io/docs/latest/plugins.html#using-plugins, i.e. set `plugins { | ||
id '[email protected]' | ||
}` in your `nextflow.config` file | ||
""") | ||
|
@@ -50,11 +50,11 @@ public class JsonSchemaValidator { | |
|
||
def Validator.Result result = this.validator.validate(schema, input) | ||
def List<String> errors = [] | ||
for (error : result.getErrors()) { | ||
result.getErrors().each { error -> | ||
def String errorString = error.getError() | ||
// Skip double error in the parameter schema | ||
if (errorString.startsWith("Value does not match against the schemas at indexes") && validationType == "parameter") { | ||
continue | ||
return | ||
} | ||
|
||
def String instanceLocation = error.getInstanceLocation() | ||
|
@@ -68,38 +68,37 @@ public class JsonSchemaValidator { | |
} | ||
|
||
// Change some error messages to make them more clear | ||
if (customError == "") { | ||
def String keyword = error.getKeyword() | ||
if (keyword == "required") { | ||
def Matcher matcher = errorString =~ ~/\[\[([^\[\]]*)\]\]$/ | ||
def String missingKeywords = matcher.findAll().flatten().last() | ||
customError = "Missing required ${validationType}(s): ${missingKeywords}" | ||
} | ||
def String keyword = error.getKeyword() | ||
if (keyword == "required") { | ||
def Matcher matcher = errorString =~ ~/\[\[([^\[\]]*)\]\]$/ | ||
def String missingKeywords = matcher.findAll().flatten().last() | ||
errorString = "Missing required ${validationType}(s): ${missingKeywords}" | ||
} | ||
|
||
def List<String> locationList = instanceLocation.split("/").findAll { it != "" } as List | ||
|
||
def String printableError = "${validationType == 'field' ? '->' : '*'} ${errorString}" as String | ||
if (locationList.size() > 0 && Utils.isInteger(locationList[0]) && validationType == "field") { | ||
def Integer entryInteger = locationList[0] as Integer | ||
def String entryString = "Entry ${entryInteger + 1}" as String | ||
def String fieldError = "" | ||
def String fieldError = "${errorString}" as String | ||
if(locationList.size() > 1) { | ||
fieldError = "Error for ${validationType} '${locationList[1..-1].join("/")}' (${value}): ${customError ?: errorString}" | ||
} else { | ||
fieldError = "${customError ?: errorString}" as String | ||
fieldError = "Error for ${validationType} '${locationList[1..-1].join("/")}' (${value}): ${errorString}" | ||
} | ||
errors.add("-> ${entryString}: ${fieldError}" as String) | ||
printableError = "-> ${entryString}: ${fieldError}" as String | ||
} else if (validationType == "parameter") { | ||
def String fieldName = locationList.join(".") | ||
if(fieldName != "") { | ||
errors.add("* --${fieldName} (${value}): ${customError ?: errorString}" as String) | ||
} else { | ||
errors.add("* ${customError ?: errorString}" as String) | ||
printableError = "* --${fieldName} (${value}): ${errorString}" as String | ||
} | ||
} else { | ||
errors.add("-> ${customError ?: errorString}" as String) | ||
} | ||
|
||
if(customError != "") { | ||
printableError = printableError + " (${customError})" | ||
} | ||
|
||
errors.add(printableError) | ||
|
||
} | ||
return errors | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters