All files / src/validation skillSchema.ts

100% Statements 24/24
100% Branches 1/1
100% Functions 1/1
100% Lines 24/24

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 401x 1x 1x                   1x 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 { makeMsg, type TFunc } from '@/libs/vee/messages'
 
export type SkillForm = {
  skillCategoryId: number | undefined;
  skillLevelId: number | undefined;
  experienceId: number | undefined;
  skillName: string | null;
  evidence: string | null;
};
 
export function makeSkillSchema(t: TFunc, L: Record<string, string>) {
  const m = makeMsg(t, L)
 
  const base = z.object({
    skillCategoryId: z
      .number()
      .int(),
 
    skillLevelId: z
      .number()
      .int(),
 
    experienceId: z
      .number()
      .int(),
 
    skillName: z
      .string()
      .min(1, m.req('skillName')),
 
    evidence: z
      .string()
      .min(1, m.req('evidence')),
  })
 
  return toTypedSchema(base)
}