Where to put Simple Schema?

Where do you write Simple Schema - https://github.com/aldeed/meteor-simple-schema? Server, Client or both?

Both! The client needs to use it for form validation, and I’ve found that having it on the server is very valuable as well, especially in generating automated exports based on the schema definition.


We have it in both too. For simple collections that means you can use it for client side validation without round-tripping the server, and then obviously you need to check again on the server before committing the data.

As a side note; ultimately you may find that you need separate client and server versions of a particular schema if you have fields that are editable on the server but not on the client (i.e. ‘system’ fields such as ‘last modified by user id’ that should never be changed by the client). One simple way to achieve that is to use sub schemas.

1 Like