PageSourceSearch

https://docs.voiden.md/assets/js/8d2d4fbc.f1511652.js

js voiden.md collected 2026-10-04 00:22:10 UTC 14,551 bytes, 1 lines download raw bytes

1"use strict";(globalThis.webpackChunkvoiden_docs=globalThis.webpackChunkvoiden_docs||[]).push([[5174],{1365:(e,t,s)=>{s.d(t,{A:()=>l});const l=s.p+"assets/images/assertion-cff92496faefa106704d2a2ab24ebc21.gif"},1698:(e,t,s)=>{s.d(t,{A:()=>l});const l=s.p+"assets/images/assertion-show-8e5218fc9472c1cc1387f660df5a2afe.png"},2095:(e,t,s)=>{s.r(t),s.d(t,{assets:()=>o,contentTitle:()=>d,default:()=>a,frontMatter:()=>r,metadata:()=>l,toc:()=>c});const l=JSON.parse('{"id":"core-features-section/voiden-blocks/assertion-block","title":"Assertion Blocks","description":"Assertions help you double-check that your API is behaving itself. Think of them as little guards that say, \u201cHey response\u2026 are you sure you\u2019re correct?\u201d","source":"@site/docs/core-features-section/voiden-blocks/assertion-block.md","sourceDirName":"core-features-section/voiden-blocks","slug":"/core-features-section/voiden-blocks/assertion-block","permalink":"/docs/core-features-section/voiden-blocks/assertion-block","draft":false,"unlisted":false,"editUrl":"https://github.com/VoidenHQ/docs/tree/main/docs/core-features-section/voiden-blocks/assertion-block.md","tags":[],"version":"current","lastUpdatedAt":1790768847000,"frontMatter":{"id":"assertion-block","title":"Assertion Blocks","sidebar_label":"Assertion Blocks"},"sidebar":"tutorialSidebar","previous":{"title":"OAuth2 Authorization Block","permalink":"/docs/core-features-section/voiden-blocks/advanced-authorization/auth-oauth2-block"},"next":{"title":"Reusable Blocks","permalink":"/docs/core-features-section/voiden-blocks/reusable-blocks"}}');var n=s(4848),i=s(8453);const r={id:"assertion-block",title:"Assertion Blocks",sidebar_label:"Assertion Blocks"},d=void 0,o={},c=[{value:"How to Use the Assertion Block",id:"how-to-use-the-assertion-block",level:3},{value:"Generate Assertions from the Response",id:"generate-assertions-from-the-response",level:3},{value:"Available Operators",id:"available-operators",level:3},{value:"Available fields",id:"available-fields",level:3},{value:"Summary",id:"summary",level:2}];function h(e){const t={blockquote:"blockquote",br:"br",code:"code",em:"em",h2:"h2",h3:"h3",hr:"hr",img:"img",li:"li",ol:"ol",p:"p",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...e.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(t.p,{children:["Assertions help you double-check that your API is behaving itself. Think of them as little guards that say, \u201cHey response\u2026 are you sure you\u2019re correct?\u201d",(0,n.jsx)(t.br,{}),"\n","Voiden proudly supports Assertions as a ",(0,n.jsx)(t.strong,{children:"reusable block"}),", because why should only your code get superpowers?"]}),"\n",(0,n.jsxs)(t.blockquote,{children:["\n",(0,n.jsxs)(t.p,{children:[(0,n.jsx)(t.strong,{children:"Note:"})," Make sure the ",(0,n.jsx)(t.strong,{children:"Assertion Plugin"})," is enabled \u2014 without it, your assertions are basically on vacation."]}),"\n"]}),"\n",(0,n.jsx)(t.hr,{}),"\n",(0,n.jsx)(t.h3,{id:"how-to-use-the-assertion-block",children:"How to Use the Assertion Block"}),"\n",(0,n.jsxs)(t.ol,{children:["\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.strong,{children:"Add the Block"}),(0,n.jsx)(t.br,{}),"\n","Type ",(0,n.jsx)(t.strong,{children:(0,n.jsx)(t.code,{children:"/assertion-block"})})," and\u2014",(0,n.jsx)(t.em,{children:"poof!"}),"\u2014your assertion template appears like a magician\u2019s trick (minus the smoke)."]}),"\n"]}),"\n",(0,n.jsx)(t.p,{children:(0,n.jsx)(t.img,{alt:"assertion",
1src:s(1698).A+"",width:"2248",height:"1446"})}),"\n",(0,n.jsx)(t.hr,{}),"\n",(0,n.jsxs)(t.ol,{start:"2",children:["\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.strong,{children:"Run It"}),(0,n.jsx)(t.br,{}),"\n","Give your request a gentle nudge by either:","\n",(0,n.jsxs)(t.ul,{children:["\n",(0,n.jsxs)(t.li,{children:["Pressing ",(0,n.jsx)(t.strong,{children:"Cmd + Enter"})," (on macOS) or ",(0,n.jsx)(t.strong,{children:"Ctrl + Enter"})," (on Windows/Linux), or"]}),"\n",(0,n.jsxs)(t.li,{children:["Clicking the big, bright ",(0,n.jsx)(t.strong,{children:"green  Play button"}),"\u2014the one that screams \u201cpress me!\u201d"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,n.jsx)(t.hr,{}),"\n",(0,n.jsxs)(t.ol,{start:"3",children:["\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.strong,{children:"Check the Results"}),(0,n.jsx)(t.br,{}),"\n","Slide over to the ",(0,n.jsx)(t.strong,{children:"Response Panel"})," \u2014 you\u2019ll spot your shiny new ",(0,n.jsx)(t.strong,{children:"Assertion Check"})," waiting to tell you if things went perfectly\u2026 or hilariously wrong."]}),"\n"]}),"\n",(0,n.jsx)(t.p,{children:(0,n.jsx)(t.img,{alt:"asserion",src:s(1365).A+"",width:"2246",height:"1444"})}),"\n",(0,n.jsx)(t.hr,{}),"\n",(0,n.jsx)(t.h3,{id:"generate-assertions-from-the-response",children:"Generate Assertions from the Response"}),"\n",(0,n.jsx)(t.p,{children:"Don't feel like writing every assertion by hand? You don't have to."}),"\n",(0,n.jsxs)(t.p,{children:["Run your request, and right on the assertion block you'll see a ",(0,n.jsx)(t.strong,{children:"Generate Assertion from Response"})," button appear. Click it and Voiden looks at what came back \u2014 request headers, response headers, and the body \u2014 and builds out assertion rows for them automatically, matched against the values you just got."]}),"\n",(0,n.jsx)(t.p,{children:(0,n.jsx)(t.img,{alt:"generate=assertion",src:s(4349).A+"",width:"2730",height:"1634"})}),"\n",(0,n.jsx)(t.p,{children:'It\'s the fastest way to lock in a "this is what a good response looks like" snapshot, which you can then tweak, trim, or loosen up as needed.'}),"\n",(0,n.jsx)(t.hr,{}),"\n",(0,n.jsx)(t.h3,{id:"available-operators",children:"Available Operators"}),"\n",(0,n.jsxs)(t.table,{children:[(0,n.jsx)(t.thead,{children:(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.th,{style:{textAlign:"left"},children:"Operator"}),(0,n.jsx)(t.th,{style:{textAlign:"left"},children:"Aliases"}),(0,n.jsx)(t.th,{style:{textAlign:"left"},children:"Description"})]})}),(0,n.jsxs)(t.tbody,{children:[(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:(0,n.jsx)(t.code,{children:"equals"})}),(0,n.jsxs)(t.td,{style:{textAlign:"left"},children:[(0,n.jsx)(t.code,{children:"eq"}),", ",(0,n.jsx)(t.code,{children:"=="}),", ",(0,n.jsx)(t.code,{children:"==="})]}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"Exact equality"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:(0,n.jsx)(t.code,{children:"not-equals"})}),(0,n.jsxs)(t.td,{style:{textAlign:"left"},children:[(0,n.jsx)(t.code,{children:"ne"}),", ",(0,n.jsx)(t.code,{children:"!="}),", ",(0,n.jsx)(t.code,{children:"!=="})]}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"Not equal"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:(0,n.jsx)(t.code,{children:"contains"})}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:(0,n.jsx)(t.code,{children:"includes"})}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"String contains"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:(0,n.jsx)(t.code,{children:"not-contains"})}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:(0,n.jsx)(t.code,{children:"not-includes"})}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"String does not contain"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:(0,n.jsx)(t.code,{children:"starts-with"})}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:(0,n.jsx)(t.code,{children:"startswith"})}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"String starts with"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:(0,n.jsx)(t.code,{children:"ends-with"})}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:(0,n.jsx)(t.code,{children:"endswith"})}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"String ends with"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:(0,n.jsx)(t.code,{children:"matches"})}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:(0,n.jsx)(t.code,{children:"regex"})}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"Regex pattern match"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:(0,n.jsx)(t.code,{children:"exists"})}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:(0,n.jsx)(t.code,{children:"is-defined"})}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"Value exists"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:(0,n.jsx)(t.code,{children:"not-exists"})}),(0,n.jsxs)(t.td,{style:{textAlign:"left"},children:[(0,n.jsx)(t.code,{children:"is-null"}),", ",(0,n.jsx)(t.code,{children:"is-undefined"})]}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"Value does not exist"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:(0,n.jsx)(t.code,{children:"greater-than"})}),(0,n.jsxs)(t.td,{style:{textAlign:"left"},children:[(0,n.jsx)(t.code,{children:"gt"}),", ",(0,n.jsx)(t.code,{children:">"})]}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"Greater than (numeric)"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:(0,n.jsx)(t.code,{children:"less-than"})}),(0,n.jsxs)(t.td,{style:{textAlign:"left"},children:[(0,n.jsx)(t.code,{children:"lt"}),", ",(0,n.jsx)(t.code,{children:"<"})]}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"Less than (numeric)"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:(0,n.jsx)(t.code,{children:"greater-equal"})}),(0,n.jsxs)(t.td,{style:{textAlign:"left"},children:[(0,n.jsx)(t.code,{children:"gte"}),", ",(0,n.jsx)(t.code,{children:">="})]}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"Greater or equal (numeric)"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:(0,n.jsx)(t.code,{children:"less-equal"})}),(0,n.jsxs)(t.td,{style:{textAlign:"left"},children:[(0,n.jsx)(t.code,{children:"lte"}),", ",(0,n.jsx)(t.code,{children:"<="})]}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"Less or equal (numeric)"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:(0,n.jsx)(t.code,{children:"is-empty"})}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:(0,n.jsx)(t.code,{children:"empty"})}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"Empty array/string/object"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:(0,n.jsx)(t.code,{children:"not-empty"})}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:(0,n.jsx)(t.em,{children:"None"})}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"Not empty"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:(0,n.jsx)(t.code,{children:"is-truthy"})}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:(0,n.jsx)(t.code,{children:"truthy"})}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"Truthy value"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:(0,n.jsx)(t.code,{children:"is-falsy"})}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:(0,n.jsx)(t.code,{children:"falsy"})}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"Falsy value"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:(0,n.jsx)(t.code,{children:"type-is"})}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:(0,n.jsx)(t.code,{children:"typeof"})}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"Type check"})]})]})]}),"\n",(0,n.jsx)(t.hr,{}),"\n",(0,n.jsx)(t.h3,{id:"available-fields",children:"Available fields"}),"\n",(0,n.jsxs)(t.table,{children:[(0,n.jsx)(t.thead,{children:(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.th,{style:{textAlign:"left"},children:"Field"}),(0,n.jsx)(t.th,{style:{textAlign:"left"},children:"Example"})]})}),(0,n.jsxs)(t.tbody,{children:[(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"status"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"200"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"statusText"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"OK"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"responseTime"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"500"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"duration"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"1000"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"header"}),(0,n.jsxs)(t.td,{style:{textAlign:"left"},children:[(0,n.jsx)(t.code,{children:"header.Content-Type"})," might have ",(0,n.jsx)(t.code,{children:"applcation/json"})]})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"body"}),(0,n.jsxs)(t.td,{style:{textAlign:"left"},children:[(0,n.jsx)(t.code,{children:"body.data[0].id"})," would read the id from ",(0,n.jsx)(t.code,{children:'{ "data": [ { "id": 0} ] }'})]})]})]})]}),"\n",(0,n.jsx)(t.hr,{}),"\n",(0,n.jsx)(t.h2,{id:"summary",children:"Summary"}),"\n",(0,n.jsxs)(t.p,{children:["Assertion blocks are your API's quality check \u2014 drop one in with ",(0,n.jsx)(t.code,{children:"/assertion-block"}),", run your request, and head over to the Response Panel to see exactly what passed and what didn't. Don't want to write them by hand? After running your request, hit ",(0,n.jsx)(t.strong,{children:"Generate Assertion from Response"})," and let Voiden build assertions from your request headers, response headers, and body for you. You can check 
1status codes, status text, response time, headers, and body fields, with a solid set of operators covering everything from simple equality to regex matching and type checks. Just make sure the Assertion Plugin is enabled and you're good to go."]})]})}function a(e={}){const{wrapper:t}={...(0,i.R)(),...e.components};return t?(0,n.jsx)(t,{...e,children:(0,n.jsx)(h,{...e})}):h(e)}},4349:(e,t,s)=>{s.d(t,{A:()=>l});const l=s.p+"assets/images/generate-assertion-232e871f57c0370cf5567a097cb014a2.gif"},8453:(e,t,s)=>{s.d(t,{R:()=>r,x:()=>d});var l=s(6540);const n={},i=l.createContext(n);function r(e){const t=l.useContext(i);return l.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function d(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(n):e.components||n:r(e.components),l.createElement(i.Provider,{value:t},e.children)}}}]);

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.