SShortSingh.
Back to feed

Developer shares practical guide to writing custom validation rules in Sanity schemas

0
·1 views

A developer has published a detailed technical guide on building custom validation rules within Sanity CMS schemas, going beyond the basic examples found in official documentation. The guide covers common production challenges such as async uniqueness checks, cross-field conditionals, and writing clear, editor-friendly error messages. Key techniques include using Rule.custom() with async callbacks to query the Sanity client directly for duplicate-value detection, such as checking whether a barcode already exists in the database. The author highlights the often-overlooked context argument, which provides access to the current document state and a pre-configured client, removing the need for separate client imports. Practical patterns like distinguishing blocking errors from non-blocking warnings are also demonstrated through real schema examples.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

OpenAI GPT-5.6 Preview Shifts AI from Model Choice to Product Architecture

OpenAI has previewed the GPT-5.6 series, introducing three model tiers — Sol (flagship), Terra (balanced), and Luna (fast and low-cost) — currently available only to select trusted partners via API and Codex. Beyond the new models, the release signals a broader shift in how software teams should approach AI integration. Rather than simply choosing the most capable model, developers are now being pushed to design workflows that can handle model changes, pricing differences, availability limits, and fallback scenarios. OpenAI also introduced new Sol modes for deeper reasoning, along with improved prompt caching features including explicit cache breakpoints and guaranteed minimum cache life. The key takeaway for SaaS builders is that the product is the workflow around the model, not the model itself — making resilience and routing strategy as important as raw model performance.

0
ProgrammingDEV Community ·

Scala-Perl Cross-Validation Uses Shared JSON Intermediate Representation

Developers building the Siunertaq system faced a common polyglot challenge: verifying that a Scala stack machine and a Perl runtime produce identical results. Rather than generating Perl code directly from Scala instructions — an approach that produced brittle, text-based tests — the team adopted a shared JSON intermediate representation. The same JSON format already used to store stack instructions in PostgreSQL was extended to serve as a universal contract consumed by three systems: a JVM evaluator, a Perl runtime, and a ClickHouse analytics pipeline. A lightweight Perl module of around 80 lines, requiring no external dependencies, parses and executes the shared JSON, keeping the generated scripts minimal. This architecture allows both runtimes to be tested against identical instruction sets, making cross-validation structural rather than textual.

0
ProgrammingDEV Community ·

Why a Green CI Pipeline Does Not Guarantee a Safe Frontend Release

A passing CI pipeline can create false confidence, as modern frontends involve complex states, browser behaviors, and asynchronous systems that most test suites do not fully cover. Real-world failures—such as Safari scroll bugs, broken RTL layouts, or CDN serving mismatched asset versions—can slip through even when all automated tests pass. Cross-browser testing must go beyond simply launching multiple browsers, since rendering differences in fonts, fractional pixels, and responsive breakpoints can cause subtle but significant issues. Localization further complicates testing, as interfaces serving Arabic, German, or currency-formatted content may behave very differently from those tested with default English data. Effective frontend testing requires selecting tests based on how a product can actually fail, not just maintaining a checklist of browsers or a suite of passing unit tests.

0
ProgrammingDEV Community ·

DEV Community Guide Shows How to Build an MCP Server Using TypeScript in 30 Minutes

Model Context Protocol (MCP) is an open standard that allows AI agents to connect to external tools and data sources through a single, reusable server. A new developer guide on DEV Community walks readers through building an MCP server from scratch using TypeScript and the official MCP SDK. The tutorial covers project setup, server configuration with Express, and registering callable tools that AI clients such as Claude and Cursor can discover and use. The guide adopts a stateless architecture, creating a fresh server instance per request to support load balancing without sticky sessions. By the end of the walkthrough, developers are expected to have a functioning MCP server capable of handling AI-initiated queries against a custom dataset or API.

Developer shares practical guide to writing custom validation rules in Sanity schemas · ShortSingh