diff --git a/CHANGELOG.md b/CHANGELOG.md index 829bea3..10258c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ ## Bug fixes 1. Fixed a bug in `samplesheetToList` that caused output mixing when the function was used more than once in channel operators. +2. Added a missing depencency for email format validation. ## Improvements diff --git a/plugins/nf-schema/build.gradle b/plugins/nf-schema/build.gradle index 3d72ac6..c4ee257 100644 --- a/plugins/nf-schema/build.gradle +++ b/plugins/nf-schema/build.gradle @@ -56,6 +56,7 @@ dependencies { compileOnly 'org.pf4j:pf4j:3.4.1' implementation 'org.json:json:20240303' implementation 'dev.harrel:json-schema:1.5.0' + implementation 'com.sanctionco.jmail:jmail:1.6.3' // Needed for e-mail format validation // test configuration testImplementation "io.nextflow:nextflow:$nextflowVersion" diff --git a/plugins/nf-schema/src/test/nextflow/validation/ValidateParametersTest.groovy b/plugins/nf-schema/src/test/nextflow/validation/ValidateParametersTest.groovy index a640791..dd2cbb5 100644 --- a/plugins/nf-schema/src/test/nextflow/validation/ValidateParametersTest.groovy +++ b/plugins/nf-schema/src/test/nextflow/validation/ValidateParametersTest.groovy @@ -1093,4 +1093,56 @@ class ValidateParametersTest extends Dsl2Spec{ !stdout } + def 'should validate an email' () { + given: + def schema = Path.of('src/testResources/nextflow_schema.json').toAbsolutePath().toString() + def SCRIPT = """ + params.input = 'src/testResource/samplesheet.csv' + params.outdir = 'src/testResources/testDir' + params.email = "test@domain.com" + include { validateParameters } from 'plugin/nf-schema' + + validateParameters(parameters_schema: '$schema') + """ + + when: + def config = [:] + def result = new MockScriptRunner(config).setScript(SCRIPT).execute() + def stdout = capture + .toString() + .readLines() + .findResults {it.contains('WARN nextflow.validation.SchemaValidator') || it.startsWith('* --') ? it : null } + + then: + noExceptionThrown() + !stdout + } + + def 'should validate an email - failure' () { + given: + def schema = Path.of('src/testResources/nextflow_schema.json').toAbsolutePath().toString() + def SCRIPT = """ + params.input = 'src/testResource/samplesheet.csv' + params.outdir = 'src/testResources/testDir' + params.email = "thisisnotanemail" + include { validateParameters } from 'plugin/nf-schema' + + validateParameters(parameters_schema: '$schema') + """ + + when: + def config = [:] + def result = new MockScriptRunner(config).setScript(SCRIPT).execute() + def stdout = capture + .toString() + .readLines() + .findResults {it.contains('WARN nextflow.validation.SchemaValidator') || it.startsWith('* --') ? it : null } + + + then: + def error = thrown(SchemaValidationException) + error.message.contains("* --email (thisisnotanemail): \"thisisnotanemail\" is not a valid email address") + !stdout + } + } \ No newline at end of file diff --git a/plugins/nf-schema/src/testResources/nextflow_schema.json b/plugins/nf-schema/src/testResources/nextflow_schema.json index 7dcf103..1fb1565 100644 --- a/plugins/nf-schema/src/testResources/nextflow_schema.json +++ b/plugins/nf-schema/src/testResources/nextflow_schema.json @@ -30,9 +30,9 @@ "email": { "type": "string", "description": "Email address for completion summary.", + "format": "email", "fa_icon": "fas fa-envelope", - "help_text": "Set this parameter to your e-mail address to get a summary e-mail with details of the run sent to you when the workflow exits. If set in your user config file (`~/.nextflow/config`) then you don't need to specify this on the command line for every run.", - "pattern": "^([a-zA-Z0-9_\\-\\.]+)@([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{2,5})$" + "help_text": "Set this parameter to your e-mail address to get a summary e-mail with details of the run sent to you when the workflow exits. If set in your user config file (`~/.nextflow/config`) then you don't need to specify this on the command line for every run." }, "multiqc_title": { "type": "string",