Form Input Validation with Meteor

meteor

Meteor doesn't have a built in validation smart package yet. What validation libraries should I consider? What are other people using?

Best Answer

We decided to use simpleSchema with Collection2 and autoform for validation. It's a very sophisticated solution. We save a lot of time using this approach rather than trying to roll each form by hand.

Simply by defining a scheme with validation rules (validation rules are provided automatically for data type and isRequired settings) then creating a form with autoForm (a single line of code) and you get all this for free

  • An autogenerated form that uses bootstrap3 classes.
  • Appropriate HTML5 fields for all keys in your collection schema.
  • A submit button that gathers the entered values and inserts them into your collection.
  • Form validation based on the schema attached to your collection. By default the form is validated when the user submits. If anything is invalid, the form is continually re-validated on keyup (throttled) as the user fixes the issues.
  • Default validation error messages that appear under the fields, and can be customized and translated.

meteor-simple-schema A simple, reactive schema validation smart package for Meteor. https://github.com/aldeed/meteor-simple-schema

meteor-collection2 A smart package for Meteor that extends Meteor.Collection to provide support for specifying a schema and then validating against that schema when inserting and updating. Also adds support for virtual fields. https://github.com/aldeed/meteor-collection2

meteor-autoform A smart package for Meteor that adds UI components and helpers to easily create basic forms with automatic insert and update events, and automatic reactive validation. https://github.com/aldeed/meteor-autoform

Related Topic