Simple Schema 3

Some of you may have experienced issues after upgrading simpl-schema to 3.x as it has dropped Meteor support. Now this is a problem, since a few packages, namely Collection2 or AutoForm still rely on this heavily.

I already proposed to re-use the old aldeed:simple-schema namespace to create and maintain a wrapper package that uses the latest Simple Schema from npm but adds all the missing Tracker integration, RegExes etc. so we can all continue focusing on other things.

However, this seems not to be the easiest thing as involves monkey patching a few prototype functions of SimpleSchema.

I hope this will not become a bigger problem than expected.

Related:

Please go to the links and thumbs up or join the discussions

3 Likes

I know it dropped support for the RegEx validations b/c of some perceived RegEx vuln. Are you sure it dropped Meteor support entirely?

I have multiple projects with 3 and collection2 + autoform with no issues. What issues are you having?

It dropped MessageBox, Tracker integration and the RegEx but apart from that it remained the same. If you don’t make use of these features then you should face no issues.

The most issues will occur if you use reactive labels or reactive validation messages. In AutoForm you will have no reactive validation out of the box when using hooks, see Validation messages not showing · Issue #1722 · Meteor-Community-Packages/meteor-autoform · GitHub

I have just checked out v3 and I have a problem with uniforms and SimpleSchema2Bridge (duh… :roll_eyes:). There seem to be changes that will have to be addressed with a new bridge version. bridge.getSubfields does not seem to work anymore (I use that in my mongo db query editor).

I had been meaning to contact you about this for the last month or so Jan :laughing:

We had been using a fork anyway of simpl-schema before this latest version because nested schema validation didn’t work. What we did recently was take the final v1 (before he jumped to v3) and then applied @znewsham’s fix for the nested schema bug. We also changed the structure so the package.json is in the root so you can import without publishing. Our fork is here.

If MCP was going to take it on I’d pretty much grab exactly this. I’m not sure it’s worth putting in much effort to rewrite elements that have been removed in v3 as I don’t think there are any new features except TS support.

2 Likes

@jkuester behind on stuff. I will look into it at earliest opportunity. @marklynch if you would be interested in helping to maintain the fork that would make it easier.

Hey Jan, yes, we’ll need something for ourselves anyway so happy to process PRs etc.

Follow-up on this topic: it’s really hard since the API changed and I still have not 100% understood what is now usable and what not.

I created a repo, solely for the purpose of migration until we have the meteor packeg (‘aldeed:simple-schema’) moved to MCP.

The repo is: https://github.com/jankapunkt/simple-schema-3

5 Likes

Just encountered an issue with the npm version (blocker is Meteor 3.0)

What exactly is the blocker there?

Here is the current requirement of simpl-schema
Screenshot from 2023-02-14 23-20-19

Although I am no longer getting the error now.

I tried to address this and have npm dependency down to 6. Improper matching of Node and NPM dependencies · Issue #473 · longshotlabs/simpl-schema · GitHub

2 Likes

Is it possible to migrate to Simple-Schema version 3, using Meteor 3 rc.4?

It depends! If you don’t need any reactivity and no async validation then you can use the version 3 of the npm package.

However, if you need any reactivity, such as in AutoForm or you have computed fields or autovalues then you won’t be able to call any collections when validating on the server. On the client you can still use the sync methods of minimongo.

This is the reason why we are working on a hard fork for the meteor package.