소스 정보
- 저장소
- dallay/profiletailors.com
- 최근 소스 활동
- 2026년 6월 12일 14:19
- 감지된 SKILL.md 언어
- 영어
- 스타
- 1
- 포크
- 0
설치 방법
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
소스 파일 검토
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
메뉴
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/dallay/profiletailors.com --skill zod-4명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
Use when writing Playwright tests, fixing flaky tests, debugging failures, implementing Page Object Model, configuring CI/CD, optimizing performance, mocking APIs, handling authentication or OAuth, testing accessibility (axe-core), file uploads/downloads, date/time mocking, WebSockets, geolocation, permissions, multi-tab/popup flows, mobile/responsive layouts, touch gestures, GraphQL, error handling, offline mode, multi-user collaboration, third-party services (payments, email verification), console error monitoring, global setup/teardown, test annotations (skip, fixme, slow), test tags (@smoke, @fast, @critical, filtering with --grep), project dependencies, security testing (XSS, CSRF, auth), performance budgets (Web Vitals, Lighthouse), iframes, component testing, canvas/WebGL, service workers/PWA, test coverage, i18n/localization, Electron apps, or browser extension testing. Covers E2E, component, API, visual, accessibility, security, Electron, and extension testing.
Use when creating features, domain models, use cases, or organizing backend code with Hexagonal Architecture (Ports and Adapters) and CQRS.
Use when bootstrapping a new Spring Boot 4 backend from Spring Initializr, choosing Kotlin + WebFlux + Gradle defaults, defining a hexagonal package-by-feature structure, and wiring local development services for a reactive stack.
SOC 직업 분류 기준
SKILL.md 표시 중
| name | zod-4 |
| description | Use when using Zod for validation, especially with breaking changes from v3. |
| allowed-tools | Read, Edit, Write, Glob, Grep, Bash, WebFetch, WebSearch, Task |
This document outlines best practices for using Zod 4 in Astro and Vue projects, focusing on schema definitions, parsing, transformations, error handling, and form integration.
// ⚠️ Deprecated (still works in v4, will be removed in v5)
z.string().email()
z.string().uuid()
z.string().url()
z.string().nonempty()
z.string().min(5, {message: "Too short"})
// ✅ Recommended (better performance, tree-shaking)
z.email()
z.uuid()
z.url()
z.string().min(1)
z.string().min(5, {error: "Too short"})
// Note: Old patterns still work in v4 for backward compatibility
// Both work in Zod 4, but 'error' is preferred
z.string().min(5, {message: "Too short"}) // ⚠️ Deprecated
z.string().min(5, {error: "Too short"}) // ✅ Preferred
// Error can be a function for dynamic messages
z.string({
error: (issue) => issue.input === undefined
? "Field is required"
: "Invalid string"
})
import {z} from "zod";
// Primitives
const stringSchema = z.string();
const numberSchema = z.number();
const booleanSchema = z.boolean();
const dateSchema = z.date();
// Top-level validators (Zod 4)
const emailSchema = z.email();
const uuidSchema = z.uuid();
const urlSchema = z.url();
// With constraints
const nameSchema = z.string().min(1).max(100);
const ageSchema = z.number().int().positive().max(150);
const priceSchema = z.number().min(0).multipleOf(0.01);
const userSchema = z.object({
id: z.uuid(),
email: z.email({error: "Invalid email address"}),
name: z.string().min(1, {error: "Name is required"}),
age: z.number().int().positive().optional(),
role: z.enum(["admin", "user", "guest"]),
metadata: z.record(z.string(), z.unknown()).optional(),
});
type User = z.infer<typeof userSchema>;
// Parsing
const user = userSchema.parse(data); // Throws on error
const result = userSchema.safeParse(data); // Returns { success, data/error }
if (result.success) {
console.log(result.data);
} else {
console.log(result.error.issues);
}
// Arrays
const tagsSchema = z.array(z.string()).min(1).max(10);
const numbersSchema = z.array(z.number()).min(1);
// Records (objects with dynamic keys)
const scoresSchema = z.record(z.string(), z.number());
// { [key: string]: number }
// Tuples
const coordinatesSchema = z.tuple([z.number(), z.number()]);
// [number, number]
// Simple union
const stringOrNumber = z.union([z.string(), z.number()]);
// Discriminated union (more efficient)
const resultSchema = z.discriminatedUnion("status", [
z.object({status: z.literal("success"), data: z.unknown()}),
z.object({status: z.literal("error"), error: z.string()}),
]);
// Transform during parsing
const lowercaseEmail = z.email().transform(email => email.toLowerCase());
// Coercion (convert types)
const numberFromString = z.coerce.number(); // "42" → 42
const dateFromString = z.coerce.date(); // "2024-01-01" → Date
// Preprocessing
const trimmedString = z.preprocess(
val => typeof val === "string" ? val.trim() : val,
z.string()
);
const passwordSchema = z.string()
.min(8)
.refine(val => /[A-Z]/.test(val), {
message: "Must contain uppercase letter",
})
.refine(val => /[0-9]/.test(val), {
message: "Must contain number",
});
// With superRefine for multiple errors
const formSchema = z.object({
password: z.string(),
confirmPassword: z.string(),
}).superRefine((data, ctx) => {
if (data.password !== data.confirmPassword) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: "Passwords don't match",
path: ["confirmPassword"],
});
}
});
// Optional (T | undefined)
z.string().optional()
// Nullable (T | null)
z.string().nullable()
// Both (T | null | undefined)
z.string().nullish()
// Default values
z.string().default("unknown")
z.number().default(() => Math.random())
// Zod 4: Use 'error' param instead of 'message'
const schema = z.object({
name: z.string({error: "Name must be a string"}),
email: z.email({error: "Invalid email format"}),
age: z.number().min(18, {error: "Must be 18 or older"}),
});
// Custom error map
const customSchema = z.string({
error: (issue) => {
if (issue.code === "too_small") {
return "String is too short";
}
return "Invalid string";
},
});
<script setup lang="ts">
import {ref, computed} from 'vue';
import {z} from 'zod';
const loginSchema = z.object({
email: z.email({error: 'Invalid email address'}),
password: z.string().min(8, {error: 'Password must be at least 8 characters'}),
});
type LoginForm = z.infer<typeof loginSchema>;
const formData = ref<Partial<LoginForm>>({
email: '',
password: '',
});
const errors = ref<Partial<Record<keyof LoginForm, string>>>({});
const validateField = (field: keyof LoginForm) => {
const schema = loginSchema.pick({[field]: true});
const result = schema.safeParse({[field]: formData.value[field]});
if (!result.success) {
errors.value[field] = result.error.issues[0]?.message;
} else {
delete errors.value[field];
}
};
const handleSubmit = async () => {
const result = loginSchema.safeParse(formData.value);
if (!result.success) {
errors.value = {};
result.error.issues.forEach(issue => {
const field = issue.path[0] as keyof LoginForm;
errors.value[field] = issue.message;
});
return;
}
console.log('Form submitted:', result.data);
// Send to API
};
</script>
<template>
<form @submit.prevent="handleSubmit" class="space-y-4">
<div>
<input
v-model="formData.email"
type="email"
placeholder="Email"
@blur="validateField('email')"
:class="{ 'border-red-500': errors.email }"
/>
<span v-if="errors.email" class="text-red-500 text-sm">{{ errors.email }}</span>
</div>
<div>
<input
v-model="formData.password"
type="password"
placeholder="Password"
@blur="validateField('password')"
:class="{ 'border-red-500': errors.password }"
/>
<span v-if="errors.password" class="text-red-500 text-sm">{{ errors.password }}</span>
</div>
<button type="submit" class="px-4 py-2 bg-blue-600 text-white rounded">
Login
</button>
</form>
</template>
---
import { z } from 'zod';
const loginSchema = z.object({
email: z.email({ error: 'Invalid email address' }),
password: z.string().min(8, { error: 'Password must be at least 8 characters' }),
});
type LoginForm = z.infer<typeof loginSchema>;
let errors: Partial<Record<keyof LoginForm, string>> = {};
let submittedData: LoginForm | null = null;
if (Astro.request.method === 'POST') {
const formData = await Astro.request.formData();
const data = {
email: formData.get('email'),
password: formData.get('password'),
};
const result = loginSchema.safeParse(data);
if (!result.success) {
result.error.issues.forEach(issue => {
const field = issue.path[0] as keyof LoginForm;
errors[field] = issue.message;
});
} else {
submittedData = result.data;
// Process form: send to API, create session, etc.
}
}
---
{submittedData && (
<div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded">
Successfully logged in as {submittedData.email}
</div>
)}
<form method="POST" class="space-y-4">
<div>
<input
name="email"
type="email"
placeholder="Email"
defaultValue=""
class={errors.email ? 'border-red-500' : ''}
/>
{errors.email && <span class="text-red-500 text-sm">{errors.email}</span>}
</div>
<div>
<input
name="password"
type="password"
placeholder="Password"
defaultValue=""
class={errors.password ? 'border-red-500' : ''}
/>
{errors.password && <span class="text-red-500 text-sm">{errors.password}</span>}
</div>
<button type="submit" class="px-4 py-2 bg-blue-600 text-white rounded">
Login
</button>
</form>
For both Vue and Astro, validate on server before processing:
// Shared validation utility
import {z} from 'zod';
export const loginSchema = z.object({
email: z.email(),
password: z.string().min(8),
});
export type LoginData = z.infer<typeof loginSchema>;
export async function validateLogin(data: unknown) {
return loginSchema.safeParse(data);
}
// Usage in API endpoint or action
export async function POST({request}) {
const data = await request.json();
const result = await validateLogin(data);
if (!result.success) {
// Use flattenError for better form handling
// Returns: { formErrors: string[], fieldErrors: Record<string, string[]> }
return new Response(
JSON.stringify({errors: z.flattenError(result.)}),
{: }
);
}
(.({: }));
}
<script setup lang="ts">
import {ref} from 'vue';
const email = ref('');
const password = ref('');
const errors = ref<Record<string, string>>({});
const loading = ref(false);
const handleSubmit = async () => {
loading.value = true;
errors.value = {};
try {
const response = await fetch('/api/login', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({email: email.value, password: password.value}),
});
if (!response.ok) {
const {errors: serverErrors} = await response.json();
if (serverErrors?.fieldErrors) {
Object.entries(serverErrors.fieldErrors).forEach(([field, messages]) => {
const firstMessage = Array.isArray(messages) ? messages[0] : messages;
if (firstMessage) {
errors.value[field] = firstMessage;
}
});
}
return;
}
// Success: redirect or update state
window.location.href = '/dashboard';
} catch (error) {
errors.value.submit = 'Network error. Please try again.';
} finally {
loading.value = false;
}
};
</script>
<template>
<form @submit.prevent="handleSubmit" class="space-y-4">
<div v-if="errors.submit" class="text-red-600 text-sm">{{ errors.submit }}</div>
<div>
<input v-model="email" type="email" placeholder="Email"/>
<span v-if="errors.email" class="text-red-500 text-sm">{{ errors.email }}</span>
</div>
<div>
<input v-model="password" type="password" placeholder="Password"/>
<span v-if="errors.password" class="text-red-500 text-sm">{{ errors.password }}</span>
</div>
<button :disabled="loading" type="submit"
class="px-4 py-2 bg-blue-600 text-white rounded disabled:opacity-50">
{{ loading ? 'Logging in...' : 'Login' }}
</button>
</form>
</template>