From aaec170c4f1bd94bc32a52306260b9e1a8880782 Mon Sep 17 00:00:00 2001 From: fuenmao <980740792@qq.com> Date: Thu, 17 Sep 2026 14:33:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=BF=85=E5=A1=AB=E9=A1=B9?= =?UTF-8?q?=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OnboardingEmployeeInfoValidator.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/SimpleAdmin.Application/Services/Onboarding/PublicTask/OnboardingEmployeeInfoValidator.cs b/SimpleAdmin.Application/Services/Onboarding/PublicTask/OnboardingEmployeeInfoValidator.cs index 20733ff..b5f0271 100644 --- a/SimpleAdmin.Application/Services/Onboarding/PublicTask/OnboardingEmployeeInfoValidator.cs +++ b/SimpleAdmin.Application/Services/Onboarding/PublicTask/OnboardingEmployeeInfoValidator.cs @@ -229,7 +229,7 @@ internal static class OnboardingEmployeeInfoValidator GetRequiredRowValue(row, "location", rowNumber, "教育经历", "学校或机构"); GetRequiredRowValue(row, "content", rowNumber, "教育经历", "专业或学习内容"); GetRequiredRowValue(row, "result", rowNumber, "教育经历", "结果或学位"); - }); + }, requireAtLeastOne: true, emptyErrorMessage: "请至少添加一条教育学习经历"); } private static void ValidateWorkHistory(string json) @@ -240,7 +240,7 @@ internal static class OnboardingEmployeeInfoValidator GetRequiredRowValue(row, "companyName", rowNumber, "工作经历", "工作单位"); GetRequiredRowValue(row, "position", rowNumber, "工作经历", "担任职务"); GetRequiredRowValue(row, "leaveReason", rowNumber, "工作经历", "离职原因"); - }); + }, requireAtLeastOne: true, emptyErrorMessage: "请至少添加一条工作经历(应届生可填写兼职、在校或实习经历)"); } private static void ValidateFamilyMembers(string json) @@ -261,16 +261,22 @@ internal static class OnboardingEmployeeInfoValidator "^(1[3-9]\\d{9}|0\\d{2,3}-?\\d{7,8})$"); if (!phoneIsValid) throw Oops.Bah($"第 {rowNumber} 条家庭成员的联系电话格式不正确"); - }); + }, requireAtLeastOne: true, emptyErrorMessage: "请至少添加一位家庭成员信息"); } private static void ValidateHistoryRows( string json, string fieldName, - Action validateRow) + Action validateRow, + bool requireAtLeastOne = false, + string emptyErrorMessage = null) { if (string.IsNullOrWhiteSpace(json)) + { + if (requireAtLeastOne) + throw Oops.Bah(emptyErrorMessage ?? $"请至少添加一条{fieldName}"); return; + } try { @@ -287,6 +293,11 @@ internal static class OnboardingEmployeeInfoValidator validateRow(row, rowNumber); } + + if (requireAtLeastOne && rowNumber == 0) + { + throw Oops.Bah(emptyErrorMessage ?? $"请至少添加一条{fieldName}"); + } } catch (global::System.Text.Json.JsonException) {