import { SimpleSchema } from 'meteor/aldeed:simple-schema'; /* Extend the available options on schema definitions: * valuesLabels: Used in conjunction with allowedValues to define the text label for each value (used on forms) * textOptional: Used to allow empty strings */ SimpleSchema.extendOptions({ valuesLabels: Match.Optional([String]), textOptional: Match.Optional(Boolean) }); // Add default required validation for empty strings which can be bypassed // using textOptional=true definition SimpleSchema.addValidator(function() { if ( this.definition.optional !== true && this.definition.textOptional !== true && this.value === '' ) { return 'required'; } });