How to use the simpl-schema.RegEx 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 empiricaly / empirica / imports / core / api / players / methods.js View on Github external
// playerIds has changed since it was queried and the lobby might not
        // have any available slots left, loop and retry.
      }
    } catch (error) {
      console.error("Players.methods.ready", error);
    }
  }
});

export const updatePlayerData = new ValidatedMethod({
  name: "Players.methods.updateData",

  validate: new SimpleSchema({
    playerId: {
      type: String,
      regEx: SimpleSchema.RegEx.Id
    },
    key: {
      type: String
    },
    value: {
      type: String
    },
    append: {
      type: Boolean,
      optional: true
    },
    noCallback: {
      type: Boolean,
      optional: true
    }
  }).validator(),
github radgrad / radgrad / app / imports / api / opportunity / OpportunityCollection.js View on Github external
constructor() {
    super('Opportunity', new SimpleSchema({
      name: { type: String },
      slugID: { type: String },
      description: { type: String },
      opportunityTypeID: { type: SimpleSchema.RegEx.Id },
      sponsorID: { type: SimpleSchema.RegEx.Id },
      interestIDs: [SimpleSchema.RegEx.Id],
      semesterIDs: [SimpleSchema.RegEx.Id],
      // Optional data
      eventDate: { type: Date, optional: true },
      ice: { type: Object, optional: true, blackbox: true },
      retired: { type: Boolean, optional: true },
    }));
  }
github VulcanJS / Vulcan / packages / vulcan-users / lib / modules / schema.js View on Github external
const linkedinFirstName = Utils.getNestedProperty(user, 'services.linkedin.firstName');
      if (profileName) return profileName;
      if (twitterName) return twitterName;
      if (linkedinFirstName) return `${linkedinFirstName} ${Utils.getNestedProperty(user, 'services.linkedin.lastName')}`;
      if (user.username) return user.username;
      return undefined;
    },
    searchable: true
  },
  /**
    The user's email. Modifiable.
  */
  email: {
    type: String,
    optional: true,
    regEx: SimpleSchema.RegEx.Email,
    mustComplete: true,
    control: "text",
    insertableBy: ['guests'],
    editableBy: ['members'],
    viewableBy: ownsOrIsAdmin,
    order: 20,
    onInsert: (user) => {
      // look in a few places for the user email
      const meteorEmails = Utils.getNestedProperty(user, 'services.meteor-developer.emails');
      const facebookEmail = Utils.getNestedProperty(user, 'services.facebook.email');
      const githubEmail = Utils.getNestedProperty(user, 'services.github.email');
      const googleEmail = Utils.getNestedProperty(user, 'services.google.email');
      const linkedinEmail = Utils.getNestedProperty(user, 'services.linkedin.emailAddress');

      if (meteorEmails) return _.findWhere(meteorEmails, { primary: true }).address;
      if (facebookEmail) return facebookEmail;
github radgrad / radgrad / app / imports / api / favorite / FavoriteCareerGoalCollection.js View on Github external
constructor() {
    super('FavoriteCareerGoal', new SimpleSchema({
      careerGoalID: SimpleSchema.RegEx.Id,
      studentID: SimpleSchema.RegEx.Id,
      retired: { type: Boolean, optional: true },
    }));
    this.publicationNames = {
      scoreboard: `${this._collectionName}.scoreboard`,
    };
  }
github radgrad / radgrad / app / imports / api / degree-plan / AcademicPlanCollection.js View on Github external
constructor() {
    super('AcademicPlan', new SimpleSchema({
      name: String,
      description: String,
      slugID: SimpleSchema.RegEx.Id,
      degreeID: SimpleSchema.RegEx.Id,
      effectiveSemesterID: SimpleSchema.RegEx.Id,
      semesterNumber: Number,
      year: Number,
      coursesPerSemester: { type: Array, minCount: 12, maxCount: 15 }, 'coursesPerSemester.$': Number,
      courseList: [String],
      retired: { type: Boolean, optional: true },
    }));
    if (Meteor.server) {
      this._collection._ensureIndex({ _id: 1, degreeID: 1, effectiveSemesterID: 1 });
    }
  }
github reactioncommerce / reaction / imports / node-app / core-services / account / simpleSchemas.js View on Github external
* @name Email
 * @memberof Schemas
 * @type {SimpleSchema}
 * @property {String} provides optional
 * @property {String} address required
 * @property {Boolean} verified optional
 */
const Email = new SimpleSchema({
  provides: {
    type: String,
    defaultValue: "default",
    optional: true
  },
  address: {
    type: String,
    regEx: SimpleSchema.RegEx.Email
  },
  verified: {
    type: Boolean,
    defaultValue: false,
    optional: true
  }
});

/**
 * @name Account
 * @memberof Schemas
 * @type {SimpleSchema}
 * @property {String} userId required
 * @property {String[]} sessions optional, Array of strings
 * @property {String} shopId optional
 * @property {String} name optional
github reactioncommerce / reaction / imports / collections / schemas / social.js View on Github external
import SimpleSchema from "simpl-schema";
import { registerSchema } from "@reactioncommerce/schemas";
import { PackageConfig } from "./registry";

/**
 * @name SocialProvider
 * @memberof Schemas
 * @type {SimpleSchema}
 * @property {String} profilePage optional, Profile Page
 * @property {Boolean} enabled optional, default value: `false`
 */
export const SocialProvider = new SimpleSchema({
  profilePage: {
    type: String,
    regEx: SimpleSchema.RegEx.Url,
    label: "Profile Page",
    optional: true
  },
  enabled: {
    type: Boolean,
    label: "Enabled",
    defaultValue: false,
    optional: true
  }
});

registerSchema("SocialProvider", SocialProvider);

/**
 * @name SocialPackageConfig
 * @memberof Schemas
github radgrad / radgrad / app / imports / api / favorite / FavoriteAcademicPlanCollection.js View on Github external
constructor() {
    super('FavoriteAcademicPlan', new SimpleSchema({
      academicPlanID: SimpleSchema.RegEx.Id,
      studentID: SimpleSchema.RegEx.Id,
      retired: { type: Boolean, optional: true },
    }));
    this.publicationNames = {
      scoreboard: `${this._collectionName}.scoreboard`,
    };
  }
github reactioncommerce / reaction / lib / collections / schemas / analytics.js View on Github external
regEx: SimpleSchema.RegEx.Id,
    optional: true,
    autoValue() {
      return Meteor.userId();
    }
  },
  "user.isAnonymous": {
    type: Boolean,
    optional: true,
    autoValue() {
      return Roles.userIsInRole(Meteor.user(), "anonymous", getShopId());
    }
  },
  "shopId": {
    type: String,
    regEx: SimpleSchema.RegEx.Id,
    autoValue: shopIdAutoValue,
    label: "AnalyticsEvents shopId"
  },
  "createdAt": {
    type: Date,
    autoValue: createdAtAutoValue
  },
  "data": {
    type: Object,
    blackbox: true,
    optional: true
  }
}, { check, tracker: Tracker });

registerSchema("AnalyticsEvents", AnalyticsEvents);
github wanglian / workbase-server / imports / channel / client / channel-modal.js View on Github external
const buildChannelFormSchema = () => {
  return new SimpleSchema({
    name: {
      type: String,
      max: 50,
      autoform: {
        type: 'text',
        label: I18n.t("channel_name")
      }
    },
    email: {
      type: String,
      max: 50,
      regEx: SimpleSchema.RegEx.Email,
      autoform: {
        type: 'emailInput',
        label: "Email"
      }
    }
  });
};