Meteor-Community-Packages / meteor-simple-schema

Meteor integration package for simpl-schema
https://github.com/Meteor-Community-Packages/meteor-simple-schema
MIT License
919 stars 161 forks source link

Warn / strip global regEx schemas? #731

Closed frrakn closed 6 years ago

frrakn commented 6 years ago

https://stackoverflow.com/questions/2630418/javascript-regex-returning-true-then-false-then-true-etc

Type checks in simple-schema-validation.js line 18 and 23 use RegExp.prototype.test. If you run the code below:

let r = /abc123/g
console.log(r.test("abc123")) // true
console.log(r.test("abc123")) // false
console.log(r.test("abc123")) // true
console.log(r.test("abc123")) // false
console.log(r.test("abc123")) // true
console.log(r.test("abc123")) // false

You can see that if you pass in a global regex to the schema, validation can alternate between true and false because javascript's global regexs are stateful

aldeed commented 6 years ago

The Meteor SimpleSchema package is no longer maintained other than critical fixes to keep it running with each latest Meteor release. Closing non-critical issues in this repo. Anyone who cares about this may do one or more of the following: