本文整理汇总了TypeScript中meteor/accounts-base.Accounts.validateNewUser方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Accounts.validateNewUser方法的具体用法?TypeScript Accounts.validateNewUser怎么用?TypeScript Accounts.validateNewUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类meteor/accounts-base.Accounts
的用法示例。
在下文中一共展示了Accounts.validateNewUser方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
requestPermissions: {
facebook: ['user_likes'],
github: ['user', 'repo']
},
requestOfflineToken: {
google: true
},
passwordSignupFields: 'USERNAME_AND_OPTIONAL_EMAIL'
});
/**
* From Accounts, Accounts.validateNewUser section
*/
Accounts.validateNewUser(function (user: { username: string }) {
if (user.username && user.username.length >= 3)
return true;
throw new Meteor.Error("403", "Username must have at least 3 characters");
});
// Validate username, without a specific error message.
Accounts.validateNewUser(function (user: { username: string }) {
return user.username !== "root";
});
/**
* From Accounts, Accounts.onCreateUser section
*/
Accounts.onCreateUser(function (options: { profile: any }, user: { profile: any, dexterity: number }) {
var d6 = function () { return Math.floor(Math.random() * 6) + 1; };
user.dexterity = d6() + d6() + d6();
// We still want the default hook's 'profile' behavior.
if (options.profile)