Skip to content

Commit

Permalink
Merge pull request #72 from nextflow-io/email-support
Browse files Browse the repository at this point in the history
add missing depedency for email format support
  • Loading branch information
nvnieuwk authored Oct 29, 2024
2 parents ede1856 + 7986be1 commit 799d0bc
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions plugins/nf-schema/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]"
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
}

}
4 changes: 2 additions & 2 deletions plugins/nf-schema/src/testResources/nextflow_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 799d0bc

Please sign in to comment.