Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can RegEx be used with Meteor "check" package?

I am relatively new to Meteor (and really like it -- thank you! framework authors).

My question is about the check package: Is there a way to call check with a RegEx pattern to validate input? I read all of the documentation for the package at the link I provided; the word "pattern" is mentioned several times, but (afaik) it was not meant to refer to a regular expression pattern.

I'm hoping I am missing something, and someone will be able to point me to a way to implement a check() call that uses a regular expression to validate a string.

like image 606
tommytwoeyes Avatar asked Aug 06 '15 23:08

tommytwoeyes


1 Answers

Yes, you can do it with the Match.Where() pattern.

Match.Where(function(str){
  check(str, String);
  var regexp = /* your RegExp */;
  return regexp.test(str);
});

(You are right that the 'patterns' referred to by the check package are not regular expression patterns; they are the 'patterns' listed in the documentation.)

like image 73
Jeremy S. Avatar answered Nov 09 '22 10:11

Jeremy S.