Skip to content

Commit

Permalink
Merge branch 'vaash/2782' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
VarunVAshrit committed Feb 17, 2025
2 parents 36e170a + 050d805 commit 334c0d7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 9 additions & 1 deletion sanityv3/schemas/objects/card.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable react/display-name */
import { configureBlockContent } from '../editors'
import type { PortableTextBlock } from 'sanity'
import type { PortableTextBlock, Rule } from 'sanity'
import { Text, Card, Box } from '@sanity/ui'
import blocksToText from '../../helpers/blocksToText'

Expand Down Expand Up @@ -49,6 +49,14 @@ export default {
{
name: 'title',
type: 'text',
validation: (Rule: Rule) =>
Rule.required()
.custom((value) => {
if (typeof value !== 'string' || value.trim() === '') {
return 'Card title cannot be empty or contain only blank spaces.';
}
return true;
}),
},
{
name: 'content',
Expand Down
6 changes: 5 additions & 1 deletion sanityv3/schemas/objects/cardsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { grid_on } from '@equinor/eds-icons'
import { configureTitleBlockContent } from '../editors'
import CompactBlockEditor from '../components/CompactBlockEditor'
import type { PortableTextBlock } from 'sanity'
import type { PortableTextBlock, Rule } from 'sanity'
import blocksToText from '../../helpers/blocksToText'
import { EdsIcon } from '../../icons'
import { Card } from './card'
Expand Down Expand Up @@ -59,6 +59,10 @@ export default {
name: 'cards',
type: 'array',
of: [{ type: 'card' }],
validation: (Rule: Rule) =>
Rule.required()
.min(1)
.error('At least one card with a valid title is required.')
},
{
title: 'The background color on the cards',
Expand Down

0 comments on commit 334c0d7

Please sign in to comment.