Skip to content

Commit

Permalink
Add EmailAddress custom schema type, use for parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
nwiltsie committed Jun 7, 2024
1 parent 840f8fc commit abf898a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
18 changes: 17 additions & 1 deletion config/custom_schema_types.config
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,27 @@ custom_schema_types {
}
}

/**
* Check that the email address matches a standard format
*/
check_email_address = { Map options, String name, Map properties ->
if (!(options[name] in String || options[name] in GString)) {
throw new Exception("${name} should have type String or GString, not ${options[name].getClass()}")
}

// If the address is not empty, ensure that it looks like an
// email address. This is a very coarse check.
if (!options[name].isEmpty() && !(options[name] ==~ /^\S+@\S+\.\S{2,}$/)) {
throw new Exception("${name} does not look like a valid email address: '${options[name]}'")
}
}

types = [
'InputNamespace': custom_schema_types.check_input_namespace,
'PatientNamespace': custom_schema_types.check_patient_namespace,
'SampleNamespace': custom_schema_types.check_sample_namespace,
'EntryList': custom_schema_types.check_entry_list,
'LaneType': custom_schema_types.check_lane_type
'LaneType': custom_schema_types.check_lane_type,
'EmailAddress': custom_schema_types.check_email_address
]
}
2 changes: 1 addition & 1 deletion config/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ clusterOptions:
allow_empty: true
help: 'Additional cluster options for use with submission command'
status_email_address:
type: 'String'
type: 'EmailAddress'
required: false
allow_empty: true
help: 'If given, the address to which pipeline start/complete notifications will be sent'
Expand Down

0 comments on commit abf898a

Please sign in to comment.