How to use the simpl-schema.oneOf 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 focallocal / fl-maps / imports / both / collections / events / index.js View on Github external
if (!this.value || this.value.length === 0) {
        return 'required'
      }
    },
    autoValue: function () {
      if (!this.field('when.multipleDays').value) {
        return null
      }

      if (this.value) {
        return this.value.map(d => !d ? false : d) // remove empty slots
      }
    }
  },
  'when.days.$': {
    type: SimpleSchema.oneOf(DaySchema, Boolean),
    required: false
  },
  'when.repeat': {
    type: Boolean,
    defaultValue: false
  },
  'when.recurring': { // used with repeat
    type: Object,
    optional: true,
    autoValue: function () {
      if (!this.field('when.repeat').value) {
        return null
      }
    }
  },
  'when.recurring.type': {
github ThaumRystra / DiceCloud / app / imports / api / properties / RollModifier.js View on Github external
});

const StoredRollModifierSchema = new SimpleSchema({
		_id: {
			type: String,
			regEx: SimpleSchema.RegEx.Id,
			autoValue(){
				if (!this.isSet) return Random.id();
			}
		},
}).extend(RollModifierSchema);

const ComputedRollModifierSchema = new SimpleSchema({
	// The computed result of the effect
	result: {
		type: SimpleSchema.oneOf(Number, String),
		optional: true,
	},
}).extend(RollModifierSchema);

export { RollModifierSchema, StoredRollModifierSchema, ComputedRollModifierSchema };
github copleykj / socialize-messaging / message-model / common / message-model.js View on Github external
if (this.isInsert && (!this.isFromTrustedCode || !this.isSet)) {
                    return this.userId;
                }
                return undefined;
            },
            index: 1,
            denyUpdate: true,
        },
        conversationId: {
            type: String,
            regEx: SimpleSchema.RegEx.Id,
            index: 1,
            denyUpdate: true,
        },
        body: {
            type: SimpleSchema.oneOf(String, Object),
        },
        createdAt: {
            type: Date,
            autoValue() {
                if (this.isInsert) {
                    return ServerTime.date();
                }
                return undefined;
            },
            index: -1,
            denyUpdate: true,
        },
        // Latest update date
        updatedAt: {
            type: Date,
            optional: true,
github focallocal / fl-maps / imports / both / collections / events / index.js View on Github external
if (!this.value || this.value.length === 0) {
        return 'required'
      }
    },
    autoValue: function () {
      if (!this.field('when.multipleDays').value) {
        return null
      }

      if (this.value) {
        return this.value.map(d => !d ? false : d) // remove empty slots
      }
    }
  },
  'when.days.$': {
    type: SimpleSchema.oneOf(DaySchema, Boolean),
    required: false
  },
  'when.repeat': {
    type: Boolean,
    defaultValue: false
  },
  'when.recurring': { // used with repeat
    type: Object,
    optional: true,
    autoValue: function () {
      if (!this.field('when.repeat').value) {
        return null
      }
    }
  },
  'when.recurring.type': {
github lianetoolkit / liane-toolkit / imports / api / mapFeatures / mapFeatures.js View on Github external
geometry: {
    type: Object
  },
  "geometry.type": {
    type: String,
    allowedValues: ["LineString", "Polygon", "Point"]
  },
  "geometry.coordinates": {
    type: Array,
    maxCount: 200
  },
  "geometry.coordinates.$": {
    type: SimpleSchema.oneOf(Number, { type: Array, maxCount: 200 })
  },
  "geometry.coordinates.$.$": {
    type: SimpleSchema.oneOf(Number, { type: Array, maxCount: 2 })
  },
  "geometry.coordinates.$.$.$": {
    type: Number
  },
  createdAt: {
    type: Date,
    autoValue() {
      if (this.isInsert) {
        return new Date();
      } else if (this.isUpsert) {
        return { $setOnInsert: new Date() };
      } else {
        return this.unset();
      }
    }
  }
github reactioncommerce / reaction / src / core-services / settings / util / settingsConfig.js View on Github external
export function runAfterUpdateHooks(context, updates, shopId) {
  Object.keys(updates).forEach((field) => {
    const config = shopId ? shopSettingsConfig[field] : globalSettingsSchema[field];
    if (!config || !config.afterUpdate) return;

    config.afterUpdate(context, { shopId, value: updates[field] });
  });
}

const configSchema = new SimpleSchema({
  "afterUpdate": {
    type: Function,
    optional: true
  },
  "defaultValue": {
    type: SimpleSchema.oneOf(String, Number, Date, Boolean),
    optional: true
  },
  "rolesThatCanEdit": {
    type: Array,
    optional: true
  },
  "rolesThatCanEdit.$": String,
  "simpleSchema": {
    type: Object,
    blackbox: true
  }
});

/**
 * @summary Reads and merges `appSettingsConfig` from all plugin registration.
 * @returns {undefined}
github Blockrazor / blockrazor / imports / api / coins / methods.js View on Github external
type: String,
        optional: true
    }
})

const editCoinFormSchema = new SimpleSchema({
    coin_id: {
        type: Id
    },
    coinName: {
        type: String,
        min: 3,
        max: 20
    },
    changed: editCoinChangedFieldSchema,
    old: SimpleSchema.oneOf({
        type: String
    }, {
            type: Number
        }),
    changedDate: {
        type: Number
    },
    createdBy: {
        type: String
    },
    score: {
        type: Number
    },
    status: {
        type: String
    },
github reactioncommerce / reaction / imports / plugins / core / settings / server / util / settingsConfig.js View on Github external
export function runAfterUpdateHooks(context, updates, shopId) {
  Object.keys(updates).forEach((field) => {
    const config = shopId ? shopSettingsConfig[field] : globalSettingsSchema[field];
    if (!config || !config.afterUpdate) return;

    config.afterUpdate(context, { shopId, value: updates[field] });
  });
}

const configSchema = new SimpleSchema({
  "afterUpdate": {
    type: Function,
    optional: true
  },
  "defaultValue": {
    type: SimpleSchema.oneOf(String, Number, Date, Boolean),
    optional: true
  },
  "rolesThatCanEdit": {
    type: Array,
    optional: true
  },
  "rolesThatCanEdit.$": String,
  "simpleSchema": {
    type: Object,
    blackbox: true
  }
});

/**
 * @summary Reads and merges `appSettingsConfig` from all plugin registration.
 * @returns {undefined}
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: {