What is wrong with using isValid() and this regex?
I'm validating US and Canadian postal codes using isValid(). US validates as expected no matter what I pass to it. It is the Canadian postal code that isn't validating the way I expect.
The regex I'm using
^[0-9]{5}(-[0-9]{4})?|^(?i)(([ABCEGHJ-NPRSTVXY][0-9][ABCEGHJ-NPRSTV-Z])( ?)([0-9])([ABCEGHJ-NPRSTV-Z]{1}[0-9]))$
Postal code
L4K 2M9
IsValid() will return true with that postal code. Add 1 or more spaces to the end of the code and it still returns valid. ReFind with the same regex works as expected. Am I missing something here?
Edit:
I just found that using param with type='regex' does the same thing.
param name='arguments.postalCode' type='regex' pattern='^[0-9]{5}(-[0-9]{4})?|^(?i)(([ABCEGHJ-NPRSTVXY]{1}[0-9]{1}[ABCEGHJ-NPRSTV-Z]{1})[ ]?([0-9]{1}[ABCEGHJ-NPRSTV-Z]{1}[0-9]{1}))$' default='12345' ;
Another Edit:
Looks like leading and trailing spaces are ignored when using regex with isValid or a param.
