Skip to content
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

add missing depedency for email format support #72

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading