本文整理匯總了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)