How to use the simpl-schema.extendOptions 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 EmurgoHK / emurpas / imports / api / example / methods.js View on Github external
// import { Meteor } from 'meteor/meteor'
import { ValidatedMethod } from 'meteor/mdg:validated-method'
import SimpleSchema from 'simpl-schema'

import { ExampleCollection } from './exampleCollection'

SimpleSchema.extendOptions(['autoform'])

// 4. after defining the schema, we have to define methods that will be used by our form
export const newExample = new ValidatedMethod({
    name: 'newExample', // this name is the method name used in quickForm template 
    validate: ExampleCollection.schema.validator({
    	clean: true, // clean has to be used here so autoValues can execute
    	filter: false // but we don't want to filter out other fields
    }),
    run({ name, description, tags, accept, numValue, number, radio, author, createdAt }) {
        // execute any arbitary code here
        
    	ExampleCollection.insert({
    		name: name,
            description: description,
            tags: tags,
            accept: accept,
github focallocal / fl-maps / imports / both / collections / events / SpecificPeriodSchema.js View on Github external
import SimpleSchema from 'simpl-schema'
import DaysSchema from './DaysSchema'

SimpleSchema.extendOptions(['uniforms'])

const SpecificPeriodSchema = new SimpleSchema({
  'startingDate': {
    type: Date,
    optional: true, // if value is null than it's a regularHours type of date
    custom: function () {
      const endingDate = this.field('when.specificPeriod.endingDate')

      if (!this.value && endingDate.value) {
        return 'required'
      }
    },
    uniforms: {
      label: 'From'
    }
  },
github arso-project / archipel / packages / app / src / features / metadata / schemas.js View on Github external
export function getCategoryFromMimeType (mime) {
  switch (mime) {
    case 'text/plain':
      return 'text'
    case 'application/pdf':
      return 'text'
    case 'image/jpeg':
      return 'image'
    default:
      return 'file'
  }
}

// SimplSchema.addValidator(singleType)
SimplSchema.extendOptions({
  singleType: Boolean
})

const resourceSchema = new SimplSchema({
  // hasLabel: String, // automatically by SimplSchema
  hasDescription: {
    type: String,
    label: 'Description'
  },
  hasTag: {
    type: String,
    label: 'Tag'
  }
})
resourceSchema.name = 'resource'
github LessWrong2 / Lesswrong2 / packages / lesswrong / lib / modules / utils / schemaUtils.js View on Github external
// of object-based.
export const addFieldsDict = (collection, fieldsDict) => {
  let translatedFields = [];
  for (let key in fieldsDict) {
    translatedFields.push({
      fieldName: key,
      fieldSchema: fieldsDict[key]
    });
  }
  collection.addField(translatedFields);
}

// For denormalized fields, needsUpdate is an optional attribute that
// determines whether the denormalization function should be rerun given
// the new document after an update or an insert
SimpleSchema.extendOptions(['needsUpdate'])

// For denormalized fields, getValue returns the new denormalized value of
// the field, given the new document after an update or an insert
SimpleSchema.extendOptions(['getValue'])

// For denormalized fields, marks a field so that we can automatically
// get the automatically recompute the new denormalized value via
// `Vulcan.recomputeDenormalizedValues` in the Meteor shell
SimpleSchema.extendOptions(['canAutoDenormalize'])


// Helper function to add all the correct callbacks and metadata for a field
// which is denormalized, where its denormalized value is a function only of
// the other fields on the document. (Doesn't work if it depends on the contents
// of other collections, because it doesn't set up callbacks for changes in
// those collections)
github espinr / activioty / controller / app / imports / api / users / users.js View on Github external
// Definition of the users and their profiles collection 
import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo';
import { Tracker } from 'meteor/tracker';
import { Roles } from 'meteor/alanning:roles';
import SimpleSchema from 'simpl-schema';
import RoleTypes from './roles/roleTypes.js';

SimpleSchema.extendOptions(['autoform']);

// Extended profile for users
const userProfilesSchema = new SimpleSchema({
  // name is used as a full name composition
  name: {
    type: String,
    optional: true,
    autoform: {
      type: 'hidden',
    },
  },
  firstName: {
    type: String,
    label: 'First Name',
    required: true,
  },
github espinr / activioty / controller / app / imports / api / competitors / competitors.js View on Github external
// Definition of the checkpoints collection
import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo';
import { Tracker } from 'meteor/tracker';
import { Checkpoints } from '../checkpoints/checkpoints.js';

import SimpleSchema from 'simpl-schema';
SimpleSchema.extendOptions(['autoform']);

export const Competitors = new Mongo.Collection('competitors');

Competitors.attachSchema(new SimpleSchema({
  bibId: {
    type: String,
    label: 'Bib ID',
    required: true,
  },
  epc: {
    type: String,
    label: 'EPC',
    optional: true,
  },
  idUser: {
    type: String,
github VulcanJS / Vulcan / packages / vulcan-lib / lib / modules / config.js View on Github external
import SimpleSchema from 'simpl-schema';

/**
 * @summary Kick off the namespace for Vulcan.
 * @namespace Vulcan
 */

// eslint-disable-next-line no-undef
Vulcan = {};

// eslint-disable-next-line no-undef
Vulcan.VERSION = '1.10.0';

// ------------------------------------- Schemas -------------------------------- //

SimpleSchema.extendOptions([
  'hidden',     // hidden: true means the field is never shown in a form no matter what
  'mustComplete', // mustComplete: true means the field is required to have a complete profile
  'form', // extra form properties
  'inputProperties', // extra form properties
  'input', // SmartForm control (String or React component)
  'control', // SmartForm control (String or React component) (legacy)
  'order', // position in the form
  'group', // form fieldset group
  'onInsert', // field insert callback
  'onEdit', // field edit callback
  'onRemove', // field remove callback
  'viewableBy', // who can view the field
  'insertableBy', // who can insert the field
  'editableBy', // who can edit the field
  'resolveAs', // field-level resolver
  'searchable', // whether a field is searchable
github espinr / activioty / controller / app / imports / api / races / races.js View on Github external
// Definition of the checkpoints collection
import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo';
import { Tracker } from 'meteor/tracker';
import { Checkpoints } from '../checkpoints/checkpoints.js';
import { Results } from '../results/results.js';
import SimpleSchema from 'simpl-schema';
SimpleSchema.extendOptions(['autoform']);

export const Races = new Mongo.Collection('races');

const checkpointsSchema = Checkpoints.simpleSchema();

const resultsSchema = Results.simpleSchema();

Races.attachSchema(new SimpleSchema({
  identifier: {
    type: String,
    label: 'Race ID',
    required: true,
  },
  description: {
    type: String,
    label: 'Description',
github focallocal / fl-maps / imports / both / collections / events / OneDaySchema.js View on Github external
import SimpleSchema from 'simpl-schema'
import * as helpers from './helpers'

SimpleSchema.extendOptions(['uniforms'])

const OneDaySchema = new SimpleSchema({
  'startingDate': {
    type: Date,
    uniforms: {
      label: 'Date'
    }
  },
  'startingTime': helpers.startingTime,
  'endingTime': helpers.endingTime
})

export default OneDaySchema
github LessWrong2 / Lesswrong2 / packages / lesswrong / lib / collections / revisions / schema.js View on Github external
import { foreignKeyField } from '../../modules/utils/schemaUtils'
import SimpleSchema from 'simpl-schema'

export const ContentType = new SimpleSchema({
  type: String,
  data: SimpleSchema.oneOf(
    String,
    {
      type: Object,
      blackbox: true
    }
  )
})

SimpleSchema.extendOptions([ 'inputType' ]);

const schema = {
  _id: {
    type: String,
    viewableBy: ['guests'],
  },
  documentId: {
    type: String,
  },
  fieldName: {
    type: String,
  },
  editedAt: {
    type: Date,
    optional: true, 
    viewableBy: ['guests'],