Menu

#2814 Verify Regex constraint on resourceURI

nextrelease
open-fixed
nobody
None
5
2026-03-20
2026-03-19
No

Here's a nice example where a regex constraint on the resourceURI parameter would work nicely:

filen= getParam( 'resourceURI', 'file:/home/jbf/tmp/voyager-1-pws-sa/data/2020/vg1pws_lr_20200101_v5.30.cdf', 'The CDF file' )

if not filen.endswith('.cdf'):
    raise Exception('filename should end in .cdf')

The check for endswith .cdf would not be necessary. The scientist would get a consistent and clear error message (make sure this is the case, don't use regex in the error message), and a file browser on getParam could limit the files displayed to those which match.

Discussion

  • Jeremy Faden

    Jeremy Faden - 2026-03-19
    filen= getParam( 'resourceURI', 'file:/home/jbf/tmp/voyager-1-pws-sa/data/2020/vg1pws_lr_20200101_v5.30.cdf', 'The CDF file', {'regex':'.*\.cdf'} )
    
     
  • Jeremy Faden

    Jeremy Faden - 2026-03-19

    Also consider a constraint on resourceURI like "fileExtension" so that those not familiar with regular expressions can use the feature.

     
  • Jeremy Faden

    Jeremy Faden - 2026-03-20

    This is verified. The regex constraint works for any parameter.

    I've also added a glob constraint, since files are ubiquitous, so {'glob':'*.cdf' } can be used.

     
  • Jeremy Faden

    Jeremy Faden - 2026-03-20
    • status: open --> open-fixed
     
MongoDB Logo MongoDB