本文整理汇总了TypeScript中server/libs/validator.accountName函数的典型用法代码示例。如果您正苦于以下问题:TypeScript accountName函数的具体用法?TypeScript accountName怎么用?TypeScript accountName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了accountName函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
test.serial('アカウント名検証 - 長すぎる時は失敗すること', (t) =>
{
const log = slog.stepIn('test', t['_test'].title);
const accountName = '123456789012345678901';
const result = Validator.accountName(accountName, locale);
const {status} = result;
log.d(JSON.stringify(result, null, 2));
t.is(status, Response.Status.FAILED);
log.stepOut();
});
示例2: isSetAccountValid
export async function isSetAccountValid(param : Request.SetAccount, myAccountId : number, locale : string) : Promise<ValidationResult>
{
const log = slog.stepIn('SettingsApi', 'isSetAccountValid');
const response : Response.SetAccount = {status:Response.Status.OK, message:{}};
const {name, userName, countryCode, phoneNo, twoFactorAuth} = param;
do
{
// アカウント名チェック
const accountNameResult = Validator.accountName(name, locale);
if (accountNameResult.status !== Response.Status.OK)
{
response.status = accountNameResult.status;
response.message.name = accountNameResult.message;
}
// ユーザー名チェック
const alreadyExistsAccount = await AccountAgent.findByUserName(userName);
const userNameResult = Validator.userName(userName, myAccountId, alreadyExistsAccount, locale);
if (userNameResult.status !== Response.Status.OK)
{
response.status = userNameResult.status;
response.message.userName = userNameResult.message;
}
// 国コードチェック
if (countryCode)
{
const countries : any[] = lookup.countries({countryCallingCodes:countryCode});
if (countries.length === 0)
{
response.status = Response.Status.FAILED;
response.message.countryCode = R.text(R.INVALID_COUNTRY_CODE, locale);
}
}
// 二段階認証方式チェック
if (twoFactorAuth === 'SMS'
|| twoFactorAuth === 'Authy')
{
if (countryCode === null || phoneNo === null)
{
response.status = Response.Status.FAILED;
response.message.phoneNo = R.text(R.REQUIRE_COUNTRY_CODE_AND_PHONE_NO, locale);
}
}
else if (twoFactorAuth !== null)
{
response.status = Response.Status.BAD_REQUEST;
response.message.general = R.text(R.BAD_REQUEST, locale);
}
}
while (false);
if (response.status !== Response.Status.OK) {
log.w(JSON.stringify(response, null, 2));
}
log.stepOut();
return {response};
}