Skip to content

Instantly share code, notes, and snippets.

@steve-ross
Created December 21, 2017 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steve-ross/e3a7c9621c0ca09dbabbde7a3a121405 to your computer and use it in GitHub Desktop.
Save steve-ross/e3a7c9621c0ca09dbabbde7a3a121405 to your computer and use it in GitHub Desktop.
Simple Schema Example for a user
import { Validator } from '../../imports/schemas/validators';
Schemas.UserProfile = new SimpleSchema({
name : {
type : String,
autoform: {
label: 'Full Name'
},
custom: Validator.twoOrMoreWords
},
phone : {
type : String,
regEx: SimpleSchema.RegEx.Phone,
autoform: {
type: 'tel',
label: 'Mobile'
}
},
alt_phone : {
type : String,
optional: true,
regEx: SimpleSchema.RegEx.Phone,
autoform: {
label: 'Alternate',
type: 'tel'
}
},
address : {
type : String,
},
unit_or_apt : {
type : String,
optional: true,
autoform: {
label: 'Unit / Apt'
}
},
city : {
type : String,
},
state : {
type : String,
allowedValues : StatesAbbreviations.values,
autoform: {
type: 'select',
options: StatesAbbreviations.options
}
},
postcode : {
type : String,
regEx : SimpleSchema.RegEx.ZipCode,
autoform: {
label: 'Zip'
}
},
notes: { // deprecated: migration 15 moves these up to the user doc for security
type: String,
optional: true
},
office: {
type: String,
allowedValues: ['Somewhere', 'Anywhere', 'Nowhere'],
optional: true,
autoform: {
type: 'select'
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment