新增 AutoRDO 需求清洗工作台与消息中枢,迭代 OneOS V2 设计规范及租赁合同/工作台/车辆等原型,同步云效技能与导航注册;并归档一批 legacy 原型快照。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
34
src/common/vehicle-purchase/vin.ts
Normal file
34
src/common/vehicle-purchase/vin.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
/** VIN 正则校验(ISO 3779 常见约束,排除 I/O/Q) */
|
||||
|
||||
const VIN_REGEX = /^[A-HJ-NPR-Z0-9]{17}$/;
|
||||
|
||||
export function normalizeVin(raw: string): string {
|
||||
return String(raw || '')
|
||||
.trim()
|
||||
.toUpperCase()
|
||||
.replace(/\s+/g, '');
|
||||
}
|
||||
|
||||
export function isValidVin(raw: string): boolean {
|
||||
return VIN_REGEX.test(normalizeVin(raw));
|
||||
}
|
||||
|
||||
export function vinValidationMessage(raw: string): string | null {
|
||||
const v = normalizeVin(raw);
|
||||
if (!v) return '请填写 VIN 码';
|
||||
if (v.length !== 17) return 'VIN 码须为 17 位';
|
||||
if (!VIN_REGEX.test(v)) return 'VIN 码格式不正确(不可含 I/O/Q,仅字母与数字)';
|
||||
return null;
|
||||
}
|
||||
|
||||
/** OCR 模拟回填样例(未接真实 OCR) */
|
||||
export const OCR_SAMPLE_VINS = [
|
||||
'LZZ1CLWB0PA123456',
|
||||
'LZZ1CLWB0PA123457',
|
||||
'LFNA1LSE5N1A88901',
|
||||
'LZZ1CLSB5PA778899',
|
||||
];
|
||||
|
||||
export function mockOcrVin(index = 0): string {
|
||||
return OCR_SAMPLE_VINS[index % OCR_SAMPLE_VINS.length];
|
||||
}
|
||||
Reference in New Issue
Block a user