How to use the simpl-schema.setDefaultMessages function in simpl-schema

To help you get started, we’ve selected a few simpl-schema examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github reactioncommerce / reaction / client / modules / i18n / startup.js View on Github external
const deps = this.validationContext && this.validationContext._deps;
    if (validationErrors) {
      const index = validationErrors.findIndex((error) => error.name === sibling && error.type === "dateBeforeNow");
      if (index !== -1) {
        validationErrors.splice(index, 1);
        if (deps) deps[sibling].changed();
      }
    }
  }
});

/**
 * Error messages that are used for all SimpleSchema instances
 * ATM, validation errors are not translated in Reaction in general.
 */
SimpleSchema.setDefaultMessages({
  messages: {
    en: {
      dateBeforeNow: "Dates in the past are not allowed."
    }
  }
});

// setup options for i18nextBrowserLanguageDetector
// note: this isn't fully operational yet
// language is set by user currently
// progress toward detecting language
// should focus around i18nextBrowserLanguageDetector
//
const options = {
  // order and from where user language should be detected
  order: ["querystring", "cookie", "localStorage", "navigator", "htmlTag"],
github vazco / meteor-universe-collection / lib / UniCollectionSS.js View on Github external
'use strict';

import SimpleSchema from 'simpl-schema';
import {isObject} from './utils';

// Extend the schema options allowed by SimpleSchema
SimpleSchema.extendOptions(['autoform']);

// Define some extra validation error messages
SimpleSchema.setDefaultMessages({
    en: {
        insertNotAllowed: '[label] cannot be set during an insert',
        updateNotAllowed: '[label] cannot be set during an update'
    }
});

export default UniCollection => {

    /*
     * Public API
     */

    /**
     * UniCollection.prototype.setSchema
     * @param {String|SimpleSchema|Object} name of schema (for multi schemas) or just SimpleSchema if this is default schema
     * @param {SimpleSchema|Object} ss - SimpleSchema instance or a schema definition object from which to create a new SimpleSchema instance