Skip to content

Commit

Permalink
add custom validation for city in Project_Collection
Browse files Browse the repository at this point in the history
  • Loading branch information
milewskibogumil committed Nov 11, 2024
1 parent 6a82a22 commit 28576cd
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion apps/sanity/schema/collectionTypes/Project_Collection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,16 @@ export default defineType({
direction: "horizontal",
layout: 'radio',
},
validation: Rule => Rule.required(),
validation: Rule => [
Rule.required(),
Rule.custom((value, context) => {
const name = (context.parent as { name: string })?.name;
if (name && value && name.includes(value)) {
return true;
}
return 'Zweryfikuj poprawność miasta'
}).warning(),
],
}),
defineField({
name: 'startDate',
Expand Down

0 comments on commit 28576cd

Please sign in to comment.