Conditional field validation based on other field values
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- typescript
- Domain
- content
Research direction
The issue names no files, tests, or entry points; begin by locating the TypeScript implementation of Keystatic field validation and object-field schema handling. Define and verify sibling-dependent isRequired behavior using the image/alt example, with coverage for both null and non-null image values.
Written by the indexing model from the issue text.
Description
Currently, Keystatic field validation (e.g., validation: { isRequired: true }) is static and cannot depend on the values of other fields in the same schema. This limitation makes it difficult to create logical validation rules for related fields.
Use Case
When working with image fields that include accessibility metadata, we want to require alt text only when an image has been uploaded. Currently, we must choose between:
- Making alt text always required (annoying when no image is uploaded)
- Making alt text optional (editors might forget to add it)
Example Schema
fields.object({
image: fields.image({
label: 'Featured Image',
directory: 'public/images',
publicPath: '/images/',
}),
alt: fields.text({
label: 'Alt Text',
// Would like: isRequired only when image is not null
validation: { isRequired: false },
}),
})
Proposed Solution
Add support for conditional validation rules:
fields.object({
image: fields.image({ /* ... */ }),
alt: fields.text({
label: 'Alt Text',
validation: {
isRequired: (values) => values.image !== null
},
}),
})
This would enable validation rules that depend on sibling field values, improving editor UX and data integrity.
Additional Context
Similar functionality exists in form libraries like React Hook Form (conditional validation) and Zod (refinements). This pattern is common in CMS tools where field relationships require contextual validation.
Note: I'm interested in contributing to Keystatic and would be happy to implement this feature if there's interest from the maintainers. Please let me know if this aligns with the project roadmap.
- Dominant language
- TypeScript
- Stars
- 2.4k
- Forks
- 159
- Avg merge
- 21h 41m
- Merged PRs (30d)
- 2
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Thinkmill/keystatic
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 70/100
All issues in Thinkmill/keystatic
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
copse-dev/agent-pane#2953 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·