如何使用simpl-schema
获取“电子邮件”属性?使用呼叫电子邮件属性时,我收到未定义的消息。不知道是否有任何更改,因为实现是根据文档进行的。
import { Meteor } from "meteor/meteor";
import SimpleSchema from "simpl-schema";
import { Accounts } from "meteor/accounts-base";
Meteor.startup(() => {
// code to run on server at startup
Accounts.validateNewUser(user => {
const email = user.emails[0].address;
try {
new SimpleSchema({
email: {
type: String,
regEx: SimpleSchema.RegEx.Email
}
}).validate({ email });
} catch (e) {
throw new Meteor.Error(400, e.message);
}
return true;
});
});