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