diff --git a/config/custom_schema_types.config b/config/custom_schema_types.config index 62ac8ee..d1db614 100644 --- a/config/custom_schema_types.config +++ b/config/custom_schema_types.config @@ -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 ] } diff --git a/config/schema.yaml b/config/schema.yaml index 89aa1c9..03894d0 100644 --- a/config/schema.yaml +++ b/config/schema.yaml @@ -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'