PageSourceSearch

https://mockoon.com/_next/static/chunks/pages/tools/yaml-validator-20e296830dd30f62.js

js mockoon.com collected 2026-10-03 19:37:55 UTC 10,363 bytes, 16 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6600],{5977:(e,s,n)=>{"use strict";n.d(s,{A:()=>i});var t=n(37876),r=n(14232);let i=function({title:e,subtitle:s,cta:n=null,ctaContent:i,mainPicture:a=null,mainPictureAlt:l=null,mainPictureWidth:o,mainPictureHeight:c,mainPictureSkewed:d,children:h}){return d=d??!0,(0,t.jsx)("section",{className:`position-relative ${a?"py-lg-10 py-5 mb-4":"pt-8 pb-4"}`,children:(0,t.jsx)("div",{className:"container",children:(0,t.jsxs)("div",{className:"row align-items-center",children:[(0,t.jsxs)("div",{className:`col-12 ${a?"col-lg-6":"col-lg-8 mx-auto text-center"}`,children:[e&&(0,t.jsx)("h1",{dangerouslySetInnerHTML:{__html:e},className:`display-4 text-center fw-medium ${a?"text-lg-start":""} `}),s&&(0,t.jsx)("p",{className:`lead ${a?"text-lg-start":""}  text-center text-gray-700 mb-6 mb-lg-8`,dangerouslySetInnerHTML:{__html:s}}),n&&(0,t.jsx)("div",{className:`hero-cta ${a?"text-lg-start":""} text-center`,children:n.map((e,s)=>(0,t.jsxs)(r.Fragment,{children:[(0,t.jsx)("a",{href:e.link,target:e.blank?"_blank":void 0,className:"me-2",children:(0,t.jsx)("button",{className:`btn btn-primary${s>0?"-subtle":""} lift`,children:(0,t.jsxs)("span",{children:[e.text," ",e.link.includes("download")&&(0,t.jsx)("i",{className:"icon-file_download ps-2"})]})})}),e.subtitle&&(0,t.jsx)("p",{className:"m-0 text-gray-700 fst-italic",children:(0,t.jsx)("small",{children:e.subt
1itle})})]},s))}),i,(0,t.jsx)("div",{className:"mt-10",children:h})]}),a&&(0,t.jsx)("div",{className:"col-12 col-lg-6 mt-10 mt-lg-0",children:(0,t.jsx)("div",{className:`${d?"skewed-screenshot":""} mb-8 mb-lg-0`,children:(0,t.jsx)("img",{src:a,alt:l,loading:"lazy",className:" img-fluid ",width:o,height:c})})})]})})})}},20471:(e,s,n)=>{"use strict";n.d(s,{A:()=>r});var t=n(37876);let r=function({colorScheme:e,children:s}){return(0,t.jsx)("div",{className:`quote bg-${e}-subtle border-start border-${e} border-4 p-4 my-4`,role:"alert",children:s})}},48061:(e,s,n)=>{"use strict";n.d(s,{A:()=>c});var t=n(37876),r=n(99946),i=n(70814),a=n(83423),l=n(85943);let o=(0,i.bu)(e=>{try{return a.Ay.load(e.state.doc.toString()),[]}catch(n){let s;return n.mark.line=n.mark.line+1,[{from:s=e.state.doc.lines<n.mark.line?e.state.doc.line(n.mark.line-1).to:e.state.doc.line(n.mark.line).from+n.mark.column,to:s,severity:"error",message:n.reason}]}},{delay:100}),c=function(e){return(0,t.jsx)(l.A,{lang:"yaml",editorExtensions:[(0,r.oQ)(),o],onErrorChange:e=>{try{return a.Ay.load(e),null}catch(e){return{message:e.message,line:e.mark.line,column:e.mark.column}}},...e})}},59751:(e,s,n)=>{"use strict";n.d(s,{A:()=>i});var t=n(37876),r=n(20471);let i=function(){return(0,t.jsxs)(r.A,{colorScheme:"secondary",children:[(0,t.jsx)("h4",{className:"fw-medium",children:"\uD83D\uDCA1 This tool is provided for free by Mockoon!"}),(0,t.jsxs)("p",{children:["Mockoon is a ",(0,t.jsx)("strong",{children:"powerful API mocking tool"})," that makes it easy to ",(0,t.jsx)("strong",{children:"create and manage mock APIs"})," for prototyping and testing. With an intuitive interface, you can quickly set up mock servers, customize responses, and simulate scenarios in real-time,"," ",(0,t.jsx)("strong",{children:"enhancing team collaboration"})," and"," ",(0,t.jsx)("strong",{children:"speeding up development"}),"."]}),(0,t.jsx)("div",{className:"mt-4",children:(0,t.jsxs)("a",{href:"/download/",className:"btn btn-primary-subtle btn-xs",children:[(0,t.jsx)("i",{className:"icon-file_download me-2"})," Download"]})})]})}},62484:(e,s,n)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/tools/yaml-validator",function(){return n(99853)}])},85943:(e,s,n)=>{"use strict";n.d(s,{A:()=>o});var t=n(37876),r=n(70814),i=n(44547),a=n(81723),l=n(14232);let o=function({value:e,lang:s,showValidMsg:n,showErrors:o,editorExtensions:c,hideGoToLine:d,onErrorChange:h,onValueChange:u}){let[m,p]=(0,l.useState)(null),x=(0,l.useRef)(null);return o=o??!0,(0,t.jsxs)("div",{className:"d-flex flex-column h-100",children:[(0,t.jsx)(a.Ay,{theme:(0,i.KL)({settings:{fontFamily:'"Fira Code", Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace'}}),extensions:[a.Lz.lineWrapping,(0,r.pJ)(),...c],basicSetup:{lintKeymap:!1},height:"100%",style:{minHeight:"0"},className:"h-100",value:e,lang:s,ref:x,onChange:(e,s)=>{h&&p(h(e,s)),u&&u(e,s)}}),m&&o&&(0,t.jsxs)("div",{className:"bg-danger-subtle border-start border-danger border-4 p-4 mt-4 position-relative d-flex justify-content-between",children:[(0,t.jsx)("div",{style:{whiteSpace:"pre-wrap",fontFamily:'"Fira Code", Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace'},children:m.message}),!d&&(0,t.jsx)("div",{className:"flex-shrink-0",children:(0,t.jsx)("a",{href:"#",onClick:e=>{e.preventDefault(),(e=>{if(!x?.current?.state?.doc)return;let s=void 0!==e.position?e.position:x.current.view.state.doc.line(e.line+1).from+e.column;x.current.view?.dispatch({selection:a.OF.single(s,s),scrollIntoView:!0})})(m)},children:"Go to line"})})]}),!m&&n&&(0,t.jsx)("div",{className:"bg-success-subtle border-start border-success border-4 p-4 mt-4",children:(0,t.jsxs)("div",{children:[s.toUpperCase()," is valid!"]})})]})}},99853:(e,s,n)=>{"use strict";n.r(s),n.d(s,{default:()=>c});var t=n(37876),r=n(48061),i=n(5977),a=n(98642),l=n(59751),o=n(33076);let c=function(){return(0,t.jsxs)(o.A,{footerBanner:"download",children:[(0,t.jsx)(a.A,{title:"Online YAML validator",description:"Mockoon's YAML validator tool: validate your YAML configuration in an online editor and get detailed error messages."}),(0,t.jsx)(i.A,{title:'Online <span class="text-primary">YAML validator</span>',subtitle:"Validate your YAML configuration online and get detailed error messages"}),(0,t.jsx)("section",{className:"pb-5 pb-lg-10",children:(0,t.jsx)("div",{className:"container",children:(0,t.jsx)("div",{className:"code-editor-container",children:(0,t.jsx)(r.A,{value:`property:
2  value: example_value
3
4  list_of_properties:
5    - property_1: value_1
6    - property_2: value_2
7    - property_3: value_3
8
9  nested_properties:
10    nested_property:
11      nested_value: nested_example_value
12
13  multiple_values_for_property:
14    - value_1
15    - value_2
16    - value_3`,showValidMsg:!0})})})}),(0,t.jsx)("section",{className:"pb-5 pb-lg-10",children:(0,t.jsx)("div",{className:"container",children:(0,t.jsx)(l.A,{})})}),(0,t.jsx)("section",{className:"pb-5 pb-lg-10",children:(0,t.jsx)("div",{className:"container",children:(0,t.jsx)("div",{className:"row",children:(0,t.jsxs)("div",{className:"col-12",children:[(0,t.jsx)("h3",{className:"fw-medium",children:"What is YAML?"}),(0,t.jsxs)("p",{children:["YAML (YAML Ain't Markup Language) is a"," ",(0,t.jsx)("strong",{children:"human-readable data serialization language"}
16)," used for configuration files and data storage or exchange. It uses a minimal syntax that relies on indentation to define the structure of the data."]}),(0,t.jsxs)("p",{children:["The official recommended extension for YAML files is"," ",(0,t.jsx)("code",{children:".yaml"}),"."]}),(0,t.jsx)("h3",{className:"mt-6 fw-medium",children:"The YAML syntax"}),(0,t.jsxs)("ul",{children:[(0,t.jsxs)("li",{children:[(0,t.jsx)("strong",{children:"Indentation"}),": YAML uses indentation to represent data structure, similar to how Python uses indentation. Indentation is used to indicate nesting."]}),(0,t.jsxs)("li",{children:[(0,t.jsx)("strong",{children:"Scalars"}),": Scalars are simple data types like strings, numbers, and booleans. They can be written as plain scalars (unquoted), single-quoted scalars, or double-quoted scalars."]}),(0,t.jsxs)("li",{children:[(0,t.jsx)("strong",{children:"Lists"}),": Lists are ordered collections of items. In YAML, lists are represented using dashes"," ",(0,t.jsx)("code",{children:"- "})," followed by a space for each item."]}),(0,t.jsxs)("li",{children:[(0,t.jsx)("strong",{children:"Dictionaries (Mappings)"}),": Dictionaries, also known as mappings or associative arrays, are collections of key-value pairs. In YAML, mappings are represented using key-value pairs separated by a colon ",(0,t.jsx)("code",{children:":"}),", with each pair on a new line and the key and value separated by whitespace."]}),(0,t.jsxs)("li",{children:[(0,t.jsx)("strong",{children:"Comments"}),": Comments in YAML start with the hash symbol ",(0,t.jsx)("code",{children:"#"}),"."]}),(0,t.jsxs)("li",{children:[(0,t.jsx)("strong",{children:"Anchors and Aliases"}),": YAML allows the reuse of data using anchors ",(0,t.jsx)("code",{children:"&"})," and aliases ",(0,t.jsx)("code",{children:"*"}),". An anchor is defined using the & symbol, and an alias refers back to that anchor using the * symbol."]}),(0,t.jsxs)("li",{children:[(0,t.jsx)("strong",{children:"Multi-line Strings"}),": YAML supports multi-line strings. Multi-line strings can be represented using the pipe",(0,t.jsx)("code",{children:"|"})," character, which preserves newlines, or the greater than ",(0,t.jsx)("code",{children:">"})," character, which folds newlines into spaces."]})]}),(0,t.jsx)("h3",{className:"mt-6 fw-medium",children:"Common errors"}),(0,t.jsx)("p",{children:"Here is a list of common errors you might encounter when writing YAML:"}),(0,t.jsxs)("ul",{children:[(0,t.jsxs)("li",{children:[(0,t.jsx)("strong",{children:"Indentation Errors"}),": YAML relies heavily on indentation to denote structure. Mixing spaces and tabs for indentation or inconsistent indentation levels can lead to syntax errors."]}),(0,t.jsxs)("li",{children:[(0,t.jsx)("strong",{children:"Missing or Misplaced Colon"}),": In mappings (key-value pairs), a colon separates the key from the value. Forgetting to include the colon or placing it incorrectly can cause parsing errors."]}),(0,t.jsxs)("li",{children:[(0,t.jsx)("strong",{children:"Incorrect Quoting"}),": Strings that contain special characters, such as colons or spaces, need to be properly quoted. Forgetting to quote strings or using the wrong type of quotes (single vs. double) can lead to interpretation errors."]}),(0,t.jsxs)("li",{children:[(0,t.jsx)("strong",{children:"Improper List Formatting"}),": Lists are denoted by using a dash (-) followed by a space for each item. Forgetting the space after the dash or mixing up list item formats can cause parsing issues."]})]})]})})})})]})}}},e=>{e.O(0,[5366,6212,1325,1991,5753,8565,9299,636,6593,8792],()=>e(e.s=62484)),_N_E=e.O()}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.