{"id":3177,"date":"2024-12-27T07:19:23","date_gmt":"2024-12-27T07:19:23","guid":{"rendered":"https:\/\/www.skybridgeinfotech.com\/blog\/?p=3177"},"modified":"2025-01-03T13:00:33","modified_gmt":"2025-01-03T13:00:33","slug":"passing-sitecore-fields-to-form-validation-schema-in-sitecore-headless-solution","status":"publish","type":"post","link":"https:\/\/www.skybridgeinfotech.com\/blog\/passing-sitecore-fields-to-form-validation-schema-in-sitecore-headless-solution\/","title":{"rendered":"Passing Sitecore Fields to Form Validation Schema in Sitecore Headless Solution"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><strong>Passing Sitecore Fields to Form Validation Schema in Sitecore Headless Solution<\/strong><\/h2>\n\n\n\n<p>In a Sitecore Headless Solution, you often need to integrate dynamic content from Sitecore into forms, such as passing Sitecore fields to a form validation schema. While accessing Sitecore item fields within a component is straightforward when the schema is defined inside the component, reusing that schema across different components can present challenges. In this blog post, we will walk through two scenarios: one where the validation schema is defined inside the component function and another where it is defined outside the component function. We will also explore how to overcome the challenges of passing Sitecore fields to a schema defined outside the component.<\/p>\n\n\n\n<p><strong>Scenario 1: Schema Defined Inside the Component Function<\/strong><\/p>\n\n\n\n<p>In the first scenario, we define a simple form within the RegisterUser component, and the validation schema is declared inside the same component function. The form contains two fields: firstName and lastName, and each field has its own validation message fetched from Sitecore fields.<\/p>\n\n\n\n<p class=\"has-ast-global-color-5-color has-text-color has-background has-link-color wp-elements-fd8afc38be679bc8a74906084f3f16ab\" style=\"background:linear-gradient(135deg,rgb(6,147,227) 8%,rgb(155,81,224) 59%)\"><strong>Here\u2019s the code for this scenario:<\/strong><\/p>\n\n\n\n<p>tsx<\/p>\n\n\n\n<p>Copy code<\/p>\n\n\n\n<p>const RegisterUser = (props: RegistrationProps): JSX.Element =&gt; {<\/p>\n\n\n\n<p>&nbsp; const schema = z.object({<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; firstName: z.string().nonEmpty({ message: props.fields.FirstNameValidation.value }),<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; lastName: z.string().nonEmpty({ message: props.fields.LastNameValidation.value }),<\/p>\n\n\n\n<p>&nbsp; });<\/p>\n\n\n\n<p>&nbsp; const form = useForm({<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; initialValues: {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; firstName: &#8221;,<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lastName: &#8221;,<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; },<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; validate: zodResolver(schema),<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; validateInputOnBlur: true,<\/p>\n\n\n\n<p>&nbsp; });<\/p>\n\n\n\n<p>&nbsp; return &lt;&gt;&lt;\/&gt;;<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<p>In this example, the props.fields.FirstNameValidation.value and props.fields.LastNameValidation.value are passed to the schema for validation messages. Since the schema is defined inside the component, it&#8217;s easy to use dynamic data from Sitecore to populate the validation messages.<\/p>\n\n\n\n<p><strong>Scenario 2: Schema Defined Outside the Component Function<\/strong><\/p>\n\n\n\n<p>Now, let\u2019s say we want to reuse the schema across different components. To achieve this, we move the validation schema outside the RegisterUser component and export it for reuse.<\/p>\n\n\n\n<p class=\"has-white-color has-text-color has-background has-link-color wp-elements-e07f88bfffead1d4549d92b596a00173\" style=\"background:linear-gradient(90deg,rgb(6,147,227) 27%,rgb(155,81,224) 55%)\"><strong>Here\u2019s how the updated code looks:<\/strong><\/p>\n\n\n\n<p>tsx<\/p>\n\n\n\n<p>Copy code<\/p>\n\n\n\n<p>const schema = z.object({<\/p>\n\n\n\n<p>&nbsp; firstName: z.string().nonEmpty({ message: &#8216;Please enter first name&#8217; }),<\/p>\n\n\n\n<p>&nbsp; lastName: z.string().nonEmpty({ message: &#8216;Please enter last name&#8217; }),<\/p>\n\n\n\n<p>});<\/p>\n\n\n\n<p>export type RegistrationForm = z.infer&lt;typeof schema&gt;;<\/p>\n\n\n\n<p>const RegisterUser = (props: RegistrationProps): JSX.Element =&gt; {<\/p>\n\n\n\n<p>&nbsp;&nbsp;const form = useForm({<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; initialValues: {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; firstName: &#8221;,<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lastName: &#8221;,<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; },<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; validate: zodResolver(schema),<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; validateInputOnBlur: true,<\/p>\n\n\n\n<p>&nbsp; });<\/p>\n\n\n\n<p>&nbsp; return &lt;&gt;&lt;\/&gt;;<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<p>In this case, the validation messages are hardcoded, and we no longer have the flexibility to pass error messages from Sitecore, since the schema is defined outside the component. So, how do we pass dynamic Sitecore fields to this schema when it\u2019s defined outside the component?<\/p>\n\n\n\n<p><strong>Solution: Convert the Schema to a Function<\/strong><\/p>\n\n\n\n<p>To solve this, we need to convert the schema into a function that accepts dynamic input, such as Sitecore field values. This way, we can still reuse the schema, while passing Sitecore-specific error messages to it.<\/p>\n\n\n\n<p class=\"has-ast-global-color-5-color has-text-color has-background has-link-color wp-elements-6886f17fd4fe5b49b00186a8f49b6df0\" style=\"background:linear-gradient(135deg,rgb(6,147,227) 22%,rgb(155,81,224) 53%)\"><strong>Here\u2019s the solution:<\/strong><\/p>\n\n\n\n<ol start=\"1\">\n<li><strong>Create a New Interface<\/strong>: Define an interface that contains only the necessary error messages from Sitecore. This improves readability and maintains separation of concerns.<\/li>\n\n\n\n<li><strong>Modify the Schema<\/strong>: Convert the schema into a function that accepts the error messages as input.<\/li>\n\n\n\n<li><strong>Pass the Sitecore Fields<\/strong>: Pass the Sitecore fields to the schema function from within the component.<\/li>\n<\/ol>\n\n\n\n<p>tsx<\/p>\n\n\n\n<p>Copy code<\/p>\n\n\n\n<p>interface RegistrationFormErrors {<\/p>\n\n\n\n<p>&nbsp; FirstNameValidation: Field&lt;string&gt;;<\/p>\n\n\n\n<p>&nbsp; LastNameValidation: Field&lt;string&gt;;<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<p>const schema = (props: RegistrationFormErrors) =&gt; {<\/p>\n\n\n\n<p>&nbsp; return z.object({<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; firstName: z.string().nonEmpty({ message: props.FirstNameValidation.value }),<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; lastName: z.string().nonEmpty({ message: props.LastNameValidation.value }),<\/p>\n\n\n\n<p>&nbsp; });<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<p>export type RegistrationForm = z.infer&lt;ReturnType&lt;typeof schema&gt;&gt;;<\/p>\n\n\n\n<p>const RegisterUser = (props: RegistrationProps): JSX.Element =&gt; {<\/p>\n\n\n\n<p>&nbsp; const form = useForm({<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; initialValues: {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; firstName: &#8221;,<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lastName: &#8221;,<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; },<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; validate: zodResolver(schema(props.fields)),<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; validateInputOnBlur: true,<\/p>\n\n\n\n<p>&nbsp; });<\/p>\n\n\n\n<p>&nbsp; return &lt;&gt;&lt;\/&gt;;<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<p><strong>Explanation of the Solution<\/strong><\/p>\n\n\n\n<ul>\n<li><strong>Interface for Error Messages<\/strong>: We define an interface RegistrationFormErrors that contains only the necessary error messages for validation.<\/li>\n\n\n\n<li><strong>Schema as a Function<\/strong>: The schema is now a function that takes props (containing Sitecore fields) and returns the validation schema. This makes it possible to pass dynamic error messages from Sitecore.<\/li>\n\n\n\n<li><strong>Usage in Component<\/strong>: In the RegisterUser component, we call the schema function and pass props.fields as an argument. This ensures that the Sitecore-specific validation messages are correctly integrated into the schema.<\/li>\n\n\n\n<li><strong>Reusability<\/strong>: With this solution, we can reuse the schema function across different components while passing dynamic Sitecore field values to customize the error messages.<\/li>\n<\/ul>\n\n\n\n<p><strong>Conclusion<\/strong><\/p>\n\n\n\n<p>Passing Sitecore fields to a form validation schema can be tricky when the schema is defined outside the component function. However, by converting the schema into a function and passing dynamic Sitecore data as input, we can overcome this challenge. This approach ensures that you can reuse your validation logic while maintaining the flexibility of dynamic content from Sitecore, making your forms both modular and customizable in a headless <strong><a href=\"https:\/\/www.skybridgeinfotech.com\/site-core.html\">Sitecore solution<\/a><\/strong>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong><em>Passing Sitecore Fields to Form Validation Schema in Sitecore Headless Solution<\/em><\/strong><\/h4>\n","protected":false},"excerpt":{"rendered":"<p>Passing Sitecore Fields to Form Validation Schema in Sitecore Headless Solution In a Sitecore Headless Solution, you often need to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3214,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"blog-details.php","format":"standard","meta":{"_acf_changed":false,"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[16],"tags":[228,254,47,48,474,235,35,49,142],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\r\n<title>Passing Sitecore Fields to Form Validation Schema in Sitecore Headless Solution<\/title>\r\n<meta name=\"description\" content=\"Passing Sitecore fields to a form validation schema can be tricky when the schema is defined outside the component function.\" \/>\r\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\r\n<link rel=\"canonical\" href=\"https:\/\/www.skybridgeinfotech.com\/blog\/passing-sitecore-fields-to-form-validation-schema-in-sitecore-headless-solution\/\" \/>\r\n<meta property=\"og:locale\" content=\"en_US\" \/>\r\n<meta property=\"og:type\" content=\"article\" \/>\r\n<meta property=\"og:title\" content=\"Passing Sitecore Fields to Form Validation Schema in Sitecore Headless Solution\" \/>\r\n<meta property=\"og:description\" content=\"Passing Sitecore fields to a form validation schema can be tricky when the schema is defined outside the component function.\" \/>\r\n<meta property=\"og:url\" content=\"https:\/\/www.skybridgeinfotech.com\/blog\/passing-sitecore-fields-to-form-validation-schema-in-sitecore-headless-solution\/\" \/>\r\n<meta property=\"og:site_name\" content=\"Skybridge\" \/>\r\n<meta property=\"article:published_time\" content=\"2024-12-27T07:19:23+00:00\" \/>\r\n<meta property=\"article:modified_time\" content=\"2025-01-03T13:00:33+00:00\" \/>\r\n<meta property=\"og:image\" content=\"http:\/\/www.skybridgeinfotech.com\/blog\/wp-content\/uploads\/2025\/01\/Passing-Sitecore-Fields-to-Form-Validation-Schema-in-Sitecore-Headless-Solutions-in-usa.jpg\" \/>\r\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\r\n\t<meta property=\"og:image:height\" content=\"800\" \/>\r\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\r\n<meta name=\"author\" content=\"admin\" \/>\r\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\r\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\r\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":[\"Article\",\"BlogPosting\"],\"@id\":\"https:\/\/www.skybridgeinfotech.com\/blog\/passing-sitecore-fields-to-form-validation-schema-in-sitecore-headless-solution\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.skybridgeinfotech.com\/blog\/passing-sitecore-fields-to-form-validation-schema-in-sitecore-headless-solution\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\/\/www.skybridgeinfotech.com\/blog\/#\/schema\/person\/0f15f3349a8eea9f6c89ae7dac0f3cbc\"},\"headline\":\"Passing Sitecore Fields to Form Validation Schema in Sitecore Headless Solution\",\"datePublished\":\"2024-12-27T07:19:23+00:00\",\"dateModified\":\"2025-01-03T13:00:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.skybridgeinfotech.com\/blog\/passing-sitecore-fields-to-form-validation-schema-in-sitecore-headless-solution\/\"},\"wordCount\":896,\"publisher\":{\"@id\":\"https:\/\/www.skybridgeinfotech.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.skybridgeinfotech.com\/blog\/passing-sitecore-fields-to-form-validation-schema-in-sitecore-headless-solution\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.skybridgeinfotech.com\/blog\/wp-content\/uploads\/2025\/01\/Passing-Sitecore-Fields-to-Form-Validation-Schema-in-Sitecore-Headless-Solutions-in-usa.jpg\",\"keywords\":[\"sitecore cms development company\",\"Sitecore CMS Implementation\",\"sitecore development\",\"sitecore development company\",\"sitecore development service\",\"Sitecore Development Services\",\"sitecore implementation partner\",\"Sitecore India\",\"Sitecore Upgrade Services\"],\"articleSection\":[\"Sitecore\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.skybridgeinfotech.com\/blog\/passing-sitecore-fields-to-form-validation-schema-in-sitecore-headless-solution\/\",\"url\":\"https:\/\/www.skybridgeinfotech.com\/blog\/passing-sitecore-fields-to-form-validation-schema-in-sitecore-headless-solution\/\",\"name\":\"Passing Sitecore Fields to Form Validation Schema in Sitecore Headless Solution\",\"isPartOf\":{\"@id\":\"https:\/\/www.skybridgeinfotech.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.skybridgeinfotech.com\/blog\/passing-sitecore-fields-to-form-validation-schema-in-sitecore-headless-solution\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.skybridgeinfotech.com\/blog\/passing-sitecore-fields-to-form-validation-schema-in-sitecore-headless-solution\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.skybridgeinfotech.com\/blog\/wp-content\/uploads\/2025\/01\/Passing-Sitecore-Fields-to-Form-Validation-Schema-in-Sitecore-Headless-Solutions-in-usa.jpg\",\"datePublished\":\"2024-12-27T07:19:23+00:00\",\"dateModified\":\"2025-01-03T13:00:33+00:00\",\"description\":\"Passing Sitecore fields to a form validation schema can be tricky when the schema is defined outside the component function.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.skybridgeinfotech.com\/blog\/passing-sitecore-fields-to-form-validation-schema-in-sitecore-headless-solution\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.skybridgeinfotech.com\/blog\/passing-sitecore-fields-to-form-validation-schema-in-sitecore-headless-solution\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.skybridgeinfotech.com\/blog\/passing-sitecore-fields-to-form-validation-schema-in-sitecore-headless-solution\/#primaryimage\",\"url\":\"https:\/\/www.skybridgeinfotech.com\/blog\/wp-content\/uploads\/2025\/01\/Passing-Sitecore-Fields-to-Form-Validation-Schema-in-Sitecore-Headless-Solutions-in-usa.jpg\",\"contentUrl\":\"https:\/\/www.skybridgeinfotech.com\/blog\/wp-content\/uploads\/2025\/01\/Passing-Sitecore-Fields-to-Form-Validation-Schema-in-Sitecore-Headless-Solutions-in-usa.jpg\",\"width\":1200,\"height\":800,\"caption\":\"Passing Sitecore Fields to Form Validation Schema in Sitecore Headless Solutions in usa\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.skybridgeinfotech.com\/blog\/passing-sitecore-fields-to-form-validation-schema-in-sitecore-headless-solution\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.skybridgeinfotech.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Passing Sitecore Fields to Form Validation Schema in Sitecore Headless Solution\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.skybridgeinfotech.com\/blog\/#website\",\"url\":\"https:\/\/www.skybridgeinfotech.com\/blog\/\",\"name\":\"Skybridge\",\"description\":\"Skybridge\",\"publisher\":{\"@id\":\"https:\/\/www.skybridgeinfotech.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.skybridgeinfotech.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.skybridgeinfotech.com\/blog\/#organization\",\"name\":\"Skybridge\",\"url\":\"https:\/\/www.skybridgeinfotech.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.skybridgeinfotech.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"http:\/\/www.skybridgeinfotech.com\/blog\/wp-content\/uploads\/2024\/02\/logo.png\",\"contentUrl\":\"http:\/\/www.skybridgeinfotech.com\/blog\/wp-content\/uploads\/2024\/02\/logo.png\",\"width\":197,\"height\":73,\"caption\":\"Skybridge\"},\"image\":{\"@id\":\"https:\/\/www.skybridgeinfotech.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.skybridgeinfotech.com\/blog\/#\/schema\/person\/0f15f3349a8eea9f6c89ae7dac0f3cbc\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.skybridgeinfotech.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/118323199c026a712094dacfeb0b28dc?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/118323199c026a712094dacfeb0b28dc?s=96&d=mm&r=g\",\"caption\":\"admin\"},\"sameAs\":[\"https:\/\/www.skybridgeinfotech.com\/blog\"],\"url\":\"https:\/\/www.skybridgeinfotech.com\/blog\/author\/admin\/\"}]}<\/script>\r\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Passing Sitecore Fields to Form Validation Schema in Sitecore Headless Solution","description":"Passing Sitecore fields to a form validation schema can be tricky when the schema is defined outside the component function.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.skybridgeinfotech.com\/blog\/passing-sitecore-fields-to-form-validation-schema-in-sitecore-headless-solution\/","og_locale":"en_US","og_type":"article","og_title":"Passing Sitecore Fields to Form Validation Schema in Sitecore Headless Solution","og_description":"Passing Sitecore fields to a form validation schema can be tricky when the schema is defined outside the component function.","og_url":"https:\/\/www.skybridgeinfotech.com\/blog\/passing-sitecore-fields-to-form-validation-schema-in-sitecore-headless-solution\/","og_site_name":"Skybridge","article_published_time":"2024-12-27T07:19:23+00:00","article_modified_time":"2025-01-03T13:00:33+00:00","og_image":[{"width":1200,"height":800,"url":"http:\/\/www.skybridgeinfotech.com\/blog\/wp-content\/uploads\/2025\/01\/Passing-Sitecore-Fields-to-Form-Validation-Schema-in-Sitecore-Headless-Solutions-in-usa.jpg","type":"image\/jpeg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["Article","BlogPosting"],"@id":"https:\/\/www.skybridgeinfotech.com\/blog\/passing-sitecore-fields-to-form-validation-schema-in-sitecore-headless-solution\/#article","isPartOf":{"@id":"https:\/\/www.skybridgeinfotech.com\/blog\/passing-sitecore-fields-to-form-validation-schema-in-sitecore-headless-solution\/"},"author":{"name":"admin","@id":"https:\/\/www.skybridgeinfotech.com\/blog\/#\/schema\/person\/0f15f3349a8eea9f6c89ae7dac0f3cbc"},"headline":"Passing Sitecore Fields to Form Validation Schema in Sitecore Headless Solution","datePublished":"2024-12-27T07:19:23+00:00","dateModified":"2025-01-03T13:00:33+00:00","mainEntityOfPage":{"@id":"https:\/\/www.skybridgeinfotech.com\/blog\/passing-sitecore-fields-to-form-validation-schema-in-sitecore-headless-solution\/"},"wordCount":896,"publisher":{"@id":"https:\/\/www.skybridgeinfotech.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.skybridgeinfotech.com\/blog\/passing-sitecore-fields-to-form-validation-schema-in-sitecore-headless-solution\/#primaryimage"},"thumbnailUrl":"https:\/\/www.skybridgeinfotech.com\/blog\/wp-content\/uploads\/2025\/01\/Passing-Sitecore-Fields-to-Form-Validation-Schema-in-Sitecore-Headless-Solutions-in-usa.jpg","keywords":["sitecore cms development company","Sitecore CMS Implementation","sitecore development","sitecore development company","sitecore development service","Sitecore Development Services","sitecore implementation partner","Sitecore India","Sitecore Upgrade Services"],"articleSection":["Sitecore"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.skybridgeinfotech.com\/blog\/passing-sitecore-fields-to-form-validation-schema-in-sitecore-headless-solution\/","url":"https:\/\/www.skybridgeinfotech.com\/blog\/passing-sitecore-fields-to-form-validation-schema-in-sitecore-headless-solution\/","name":"Passing Sitecore Fields to Form Validation Schema in Sitecore Headless Solution","isPartOf":{"@id":"https:\/\/www.skybridgeinfotech.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.skybridgeinfotech.com\/blog\/passing-sitecore-fields-to-form-validation-schema-in-sitecore-headless-solution\/#primaryimage"},"image":{"@id":"https:\/\/www.skybridgeinfotech.com\/blog\/passing-sitecore-fields-to-form-validation-schema-in-sitecore-headless-solution\/#primaryimage"},"thumbnailUrl":"https:\/\/www.skybridgeinfotech.com\/blog\/wp-content\/uploads\/2025\/01\/Passing-Sitecore-Fields-to-Form-Validation-Schema-in-Sitecore-Headless-Solutions-in-usa.jpg","datePublished":"2024-12-27T07:19:23+00:00","dateModified":"2025-01-03T13:00:33+00:00","description":"Passing Sitecore fields to a form validation schema can be tricky when the schema is defined outside the component function.","breadcrumb":{"@id":"https:\/\/www.skybridgeinfotech.com\/blog\/passing-sitecore-fields-to-form-validation-schema-in-sitecore-headless-solution\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.skybridgeinfotech.com\/blog\/passing-sitecore-fields-to-form-validation-schema-in-sitecore-headless-solution\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.skybridgeinfotech.com\/blog\/passing-sitecore-fields-to-form-validation-schema-in-sitecore-headless-solution\/#primaryimage","url":"https:\/\/www.skybridgeinfotech.com\/blog\/wp-content\/uploads\/2025\/01\/Passing-Sitecore-Fields-to-Form-Validation-Schema-in-Sitecore-Headless-Solutions-in-usa.jpg","contentUrl":"https:\/\/www.skybridgeinfotech.com\/blog\/wp-content\/uploads\/2025\/01\/Passing-Sitecore-Fields-to-Form-Validation-Schema-in-Sitecore-Headless-Solutions-in-usa.jpg","width":1200,"height":800,"caption":"Passing Sitecore Fields to Form Validation Schema in Sitecore Headless Solutions in usa"},{"@type":"BreadcrumbList","@id":"https:\/\/www.skybridgeinfotech.com\/blog\/passing-sitecore-fields-to-form-validation-schema-in-sitecore-headless-solution\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.skybridgeinfotech.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Passing Sitecore Fields to Form Validation Schema in Sitecore Headless Solution"}]},{"@type":"WebSite","@id":"https:\/\/www.skybridgeinfotech.com\/blog\/#website","url":"https:\/\/www.skybridgeinfotech.com\/blog\/","name":"Skybridge","description":"Skybridge","publisher":{"@id":"https:\/\/www.skybridgeinfotech.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.skybridgeinfotech.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.skybridgeinfotech.com\/blog\/#organization","name":"Skybridge","url":"https:\/\/www.skybridgeinfotech.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.skybridgeinfotech.com\/blog\/#\/schema\/logo\/image\/","url":"http:\/\/www.skybridgeinfotech.com\/blog\/wp-content\/uploads\/2024\/02\/logo.png","contentUrl":"http:\/\/www.skybridgeinfotech.com\/blog\/wp-content\/uploads\/2024\/02\/logo.png","width":197,"height":73,"caption":"Skybridge"},"image":{"@id":"https:\/\/www.skybridgeinfotech.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.skybridgeinfotech.com\/blog\/#\/schema\/person\/0f15f3349a8eea9f6c89ae7dac0f3cbc","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.skybridgeinfotech.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/118323199c026a712094dacfeb0b28dc?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/118323199c026a712094dacfeb0b28dc?s=96&d=mm&r=g","caption":"admin"},"sameAs":["https:\/\/www.skybridgeinfotech.com\/blog"],"url":"https:\/\/www.skybridgeinfotech.com\/blog\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.skybridgeinfotech.com\/blog\/wp-json\/wp\/v2\/posts\/3177"}],"collection":[{"href":"https:\/\/www.skybridgeinfotech.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skybridgeinfotech.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skybridgeinfotech.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skybridgeinfotech.com\/blog\/wp-json\/wp\/v2\/comments?post=3177"}],"version-history":[{"count":16,"href":"https:\/\/www.skybridgeinfotech.com\/blog\/wp-json\/wp\/v2\/posts\/3177\/revisions"}],"predecessor-version":[{"id":3201,"href":"https:\/\/www.skybridgeinfotech.com\/blog\/wp-json\/wp\/v2\/posts\/3177\/revisions\/3201"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.skybridgeinfotech.com\/blog\/wp-json\/wp\/v2\/media\/3214"}],"wp:attachment":[{"href":"https:\/\/www.skybridgeinfotech.com\/blog\/wp-json\/wp\/v2\/media?parent=3177"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skybridgeinfotech.com\/blog\/wp-json\/wp\/v2\/categories?post=3177"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skybridgeinfotech.com\/blog\/wp-json\/wp\/v2\/tags?post=3177"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}