javascript - Simple Schema error in Meteor -


i using meteor accounts , simple schema users register , enter profile information in app. defined schema users , attached schema address it. however, when go register account, keep getting error "address required" although filled out required fields address. here's schema:

schemas.useraddress = new simpleschema({ //useraddress schema defined  streetaddress: {     type: string,     max: 100,     optional: false }, city: {     type: string,     max: 50,     optional: false }, state: {         type: string,     regex: /^a[lkszraep]|c[aot]|d[ec]|f[lm]|g[au]|hi|i[adln]|k[sy]|la|m[adehinopst]|n[cdehjmvy]|o[hkr]|p[arw]|ri|s[cd]|t[nx]|ut|v[ait]|w[aivy]$/,     optional: false }, zipcode: { type: string, regex: /^[0-9]{5}$/, optional: false 

} });

var schemas = {};  schemas.userprofile = new simpleschema({ companyname: {     type: string,     regex: /^[a-za-z-]{2,25}$/,     optional: false }, tiremarkup: {     type: number,     optional: true,     min: 1 }, phonenum: {     type: string,     regex: /^[(]{0,1}[0-9]{3}[)]{0,1}[-\s\.]{0,1}[0-9]{3}[-\s\.]{0,1}[0-9]{4}$/,     optional: false     }, confirmed: {     type: boolean,     optional: true }, });   schemas.user = new simpleschema({ emails: {     type: [object],     optional: false }, "emails.$.address": {     type: string,     regex: simpleschema.regex.email }, "emails.$.verified": {     type: boolean }, createdat: {     type: date }, profile: {     type: schemas.userprofile,     optional: false }, address: { //attach user address schema     type: schemas.useraddress,      optional: false }, services: {     type: object,     optional: true,     blackbox: true } });  meteor.users.attachschema(schemas.user); 

here accounts config creates sign form:

meteor.startup(function () { accountsentry.config({   logo: '',                  // if set displays logo above sign-in options   termsurl: '/terms-of-use',         // if set adds link terms  'you agree ...' on sign-up page   homeroute: '/',                    // mandatory - path redirect after sign-out   dashboardroute: '/dashboard/',      // mandatory - path redirect after successful sign-in   profileroute: '/profile',   passwordsignupfields: 'email_only',   showotherloginservices: true,      // set false hide oauth login buttons on signin/signup pages. useful if using accounts-meld or want oauth api access   extrasignupfields: [       {         field: "companyname",                                    label: "company name",                              placeholder: "petrocon",                         type: "text",                                    required: true                              },     {         field: "firstname",                                label: "first name",                             placeholder: "john",                         type: "text",                                     required: true                                },       {         field: "lastname",                                   label: "last name",                               placeholder: "nguyen",                          type: "text",                                     required: true                               },     {   field: "streetaddress",         label: "street address",         placeholder: "12345 main street",         type: "text",         required: true     },     {   field: "city",         label: "city",         placeholder: "springfield",         type: "text",         required: true     },     {   field: "state",         label: "state",         placeholder: "missouri",         type: "text",         required: true     },     {   field: "zipcode",         label: "zip code",         placeholder: "65801",         type: "text",         required: true     },     {         field: "phonenum",                                   label: "contact number",                              placeholder: "316-000-0000",                          type: "text",                                     required: true                                }       ] }); }); 

as can see, defined of fields in address schema in accountsentry.config.. therefore don't know why when enter information in form, error 'address required'. know what's going on? thank in advance!

looks you're using accounts-entry package. can see code account created in file:

https://github.com/differential/accounts-entry/blob/9aac00cb3c67afcbb1cc990c7af1f2c7607a2337/server/entry.coffee

line 29 looks this:

profile: _.extend(profile, user.profile) 

if debug , @ value of profile after extend method called, you'll see this:

{     "companyname": "petrocon",     "firstname": "john",     "lastname": "nguyen",     "streetaddress": "12345 main street",     "city": "springfield",     "state": "missouri",     "zipcode": "65801",     "phonenum": "316-000-0000" } 

there no property named "address" schemas.user schema.

there might slick way you're looking for, easiest approach rid of schemas.useraddress schema. move properties (streetaddress, city, state, zipcode) schemas.userprofile schema , work.


Popular posts from this blog