Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | 1x 1x 1x 1x 1x 1x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x | import { z } from 'zod'
import { toTypedSchema } from '@vee-validate/zod'
// import { stringMaxOptional } from '@/libs/vee/rules'
import { makeMsg, type TFunc } from '@/libs/vee/messages'
import { emptyToNull, nullToEmpty } from '@/utils'
import { PATTERN } from "./pattern"
export type EducationFields = {
institutionName: string | null;
facultyName: string | null;
departmentName: string | null;
degreeTypeId: number;
educationStatusId: number;
enrollmentDate: string | null;
graduationDate: string | null;
description: string | null;
isPublic: boolean;
};
export function makeEducationSchema(t: TFunc, L: Record<string, string>) {
const m = makeMsg(t, L);
const base = z.object({
// 学校名
institutionName: z.preprocess(
nullToEmpty,
z
.string()
.trim()
.min(1, m.req('institutionName'))
.nonempty(m.req('institutionName')),
),
// 学部名
facultyName: z.preprocess(
emptyToNull,
z
.string()
.trim()
.nullable()
),
// 学科・選考名
departmentName: z.preprocess(
emptyToNull,
z
.string()
.trim()
.nullable()
),
// 学位種別ID
degreeTypeId: z.preprocess(
emptyToNull,
z
.number()
.int()
.nullable()
.refine(v => v !== null, {
message: m.req('degreeTypeId')
})
),
// 学歴状態ID
educationStatusId: z.preprocess(
emptyToNull,
z
.number()
.int()
.nullable()
.refine(v => v !== null, {
message: m.req('educationStatusId')
})
),
// 年月
eventDate: z.preprocess(
emptyToNull,
z
.string()
.regex(PATTERN.DATE_YM, {message: m.date('eventDate')})
// .nullable()
),
// 効果可否
isPublic: z
.boolean(),
})
return toTypedSchema(base);
}
|