Commit 583d7297 by light5980 Committed by GitHub

fix(certification): remove bank account length verification (#7369)

parent 146ade2d
...@@ -91,7 +91,7 @@ const BankAccountSchema = EnterpriseAuthRequiredStringSchema.transform((account) ...@@ -91,7 +91,7 @@ const BankAccountSchema = EnterpriseAuthRequiredStringSchema.transform((account)
) )
.pipe(z.string().refine(isBankAccount)) .pipe(z.string().refine(isBankAccount))
.meta({ .meta({
description: '企业银行账号,15-19 位数字,可输入空格分隔', description: '企业银行账号,仅支持数字,可输入空格分隔',
example: '4111111111111111' example: '4111111111111111'
}); });
const UnifiedCreditCodeSchema = EnterpriseAuthRequiredStringSchema.transform((code) => const UnifiedCreditCodeSchema = EnterpriseAuthRequiredStringSchema.transform((code) =>
......
const UnifiedCreditCodeChars = '0123456789ABCDEFGHJKLMNPQRTUWXY'; const UnifiedCreditCodeChars = '0123456789ABCDEFGHJKLMNPQRTUWXY';
const UnifiedCreditCodeWeights = [1, 3, 9, 27, 19, 26, 16, 17, 20, 29, 25, 13, 8, 24, 10, 30, 28]; const UnifiedCreditCodeWeights = [1, 3, 9, 27, 19, 26, 16, 17, 20, 29, 25, 13, 8, 24, 10, 30, 28];
const UnifiedCreditCodePattern = /^[0-9A-HJ-NP-RTUWXY]{18}$/; const UnifiedCreditCodePattern = /^[0-9A-HJ-NP-RTUWXY]{18}$/;
const BankAccountPattern = /^\d{15,19}$/; const BankAccountPattern = /^\d+$/;
export const normalizeUnifiedCreditCode = (code: string) => code.trim().toUpperCase(); export const normalizeUnifiedCreditCode = (code: string) => code.trim().toUpperCase();
...@@ -29,7 +29,7 @@ export const isUnifiedCreditCode = (code: string) => { ...@@ -29,7 +29,7 @@ export const isUnifiedCreditCode = (code: string) => {
}; };
/** /**
* 校验企业银行账号:去除空格后需为 15-19 位数字 * 校验企业银行账号:去除空格后需为纯数字,不限制账号长度
*/ */
export const isBankAccount = (account: string) => { export const isBankAccount = (account: string) => {
const normalizedAccount = normalizeBankAccount(account); const normalizedAccount = normalizeBankAccount(account);
......
...@@ -59,16 +59,18 @@ describe('StartEnterpriseAuthBodySchema', () => { ...@@ -59,16 +59,18 @@ describe('StartEnterpriseAuthBodySchema', () => {
).toBe(false); ).toBe(false);
}); });
it('银行账号需为 15-19 位数字,并在入参解析时去除空格', () => { it('银行账号不限制长度,并在入参解析时去除空格', () => {
expect(StartEnterpriseAuthBodySchema.parse(validBody).bankAccount).toBe('4111111111111111'); expect(StartEnterpriseAuthBodySchema.parse(validBody).bankAccount).toBe('4111111111111111');
['1', '1'.repeat(32)].forEach((bankAccount) => {
expect( expect(
StartEnterpriseAuthBodySchema.parse({ StartEnterpriseAuthBodySchema.parse({
...validBody, ...validBody,
bankAccount: '571919104910201' bankAccount
}).bankAccount }).bankAccount
).toBe('571919104910201'); ).toBe(bankAccount);
});
['4111-1111-1111-1111', '1'.repeat(14), '1'.repeat(20)].forEach((bankAccount) => { ['', ' ', '4111-1111-1111-1111'].forEach((bankAccount) => {
expect( expect(
StartEnterpriseAuthBodySchema.safeParse({ StartEnterpriseAuthBodySchema.safeParse({
...validBody, ...validBody,
......
Subproject commit ce171ee3520e72f63bba30aba343ffc7e0b51e65 Subproject commit d0cdce9e0de80af2ef697526da4958b6882a791f
...@@ -8,16 +8,17 @@ import { ...@@ -8,16 +8,17 @@ import {
} from '../../../../../src/pageComponents/account/team/EnterpriseAuth/shared'; } from '../../../../../src/pageComponents/account/team/EnterpriseAuth/shared';
describe('enterprise auth bank account validation', () => { describe('enterprise auth bank account validation', () => {
it('去除空格后校验 15-19 位数字银行账号', () => { it('去除空格后校验纯数字银行账号,不限制长度', () => {
expect(normalizeBankAccount(' 4111 1111 1111 1111 ')).toBe('4111111111111111'); expect(normalizeBankAccount(' 4111 1111 1111 1111 ')).toBe('4111111111111111');
expect(fieldRules.bankAccount.validate('4111 1111 1111 1111')).toBe(true); expect(fieldRules.bankAccount.validate('4111 1111 1111 1111')).toBe(true);
expect(fieldRules.bankAccount.validate('571919104910201')).toBe(true); expect(fieldRules.bankAccount.validate('1')).toBe(true);
expect(fieldRules.bankAccount.validate('1'.repeat(32))).toBe(true);
}); });
it('银行账号包含非数字或长度不符时校验失败', () => { it('银行账号为空或包含非数字时校验失败', () => {
expect(fieldRules.bankAccount.validate('')).toBe(false);
expect(fieldRules.bankAccount.validate(' ')).toBe(false);
expect(fieldRules.bankAccount.validate('4111-1111-1111-1111')).toBe(false); expect(fieldRules.bankAccount.validate('4111-1111-1111-1111')).toBe(false);
expect(fieldRules.bankAccount.validate('1'.repeat(14))).toBe(false);
expect(fieldRules.bankAccount.validate('1'.repeat(20))).toBe(false);
}); });
it('统一社会信用代码按 GB 32100-2015 校验第 18 位', () => { it('统一社会信用代码按 GB 32100-2015 校验第 18 位', () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment