1"use strict";(self.webpackChunkvolder_doc=self.webpackChunkvolder_doc||[]).push([[2687],{3905:function(e,t,n){n.d(t,{Zo:function(){return c},kt:function(){return m}});var r=n(7294);function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?l(Object(n),!0).forEach((function(t){a(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function i(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n,r,a={},l=Object.keys(e);for(r=0;r<l.length;r++)n=l[r],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(r=0;r<l.length;r++)n=l[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var s=r.createContext({}),u=function(e){var t=r.useContext(s),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},c=function(e){var t=u(e.components);return r.createElement(s.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return r.createElement(r.Fragment,{},t)}},p=r.forwardRef((function(e,t){var n=e.components,a=e.mdxType,l=e.originalType,s=e.parentName,c=i(e,["components","mdxType","originalType","parentName"]),p=u(n),m=a,v=p["".concat(s,".").concat(m)]||p[m]||d[m]||l;return n?r.createElement(v,o(o({ref:t},c),{},{components:n})):r.createElement(v,o({ref:t},c))}));function m(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var l=n.length,o=new Array(l);o[0]=p;var i={};for(var s in t)hasOwnProperty.call(t,s)&&(i[s]=t[s]);i.originalType=e,i.mdxType="string"==typeof e?e:a,o[1]=i;for(var u=2;u<l;u++)o[u]=n[u];return r.createElement.apply(null,o)}return r.createElement.apply(null,n)}p.displayName="MDXCreateElement"},8215:function(e,t,n){var r=n(7294);t.Z=function(e){var t=e.children,n=e.hidden,a=e.className;return r.createElement("div",{role:"tabpanel",hidden:n,className:a},t)}},6396:function(e,t,n){n.d(t,{Z:function(){return p}});var r=n(7462),a=n(7294),l=n(2389),o=n(9443);var i=function(){var e=(0,a.useContext)(o.Z);if(null==e)throw new Error('"useUserPreferencesContext" is used outside of "Layout" component.');return e},s=n(3616),u=n(6010),c="tabItem_vU9c";function d(e){var t,n,l,o=e.lazy,d=e.block,p=e.defaultValue,m=e.values,v=e.groupId,f=e.className,h=a.Children.map(e.children,(function(e){if((0,a.isValidElement)(e)&&void 0!==e.props.value)return e;throw new Error("Docusaurus error: Bad <Tabs> child <"+("string"==typeof e.type?e.type:e.type.name)+'>: all children of the <Tabs> component should be <TabItem>, and every <TabItem> should have a unique "value" prop.')})),b=null!=m?m:h.map((function(e){var t=e.props;return{value:t.value,label:t.label,attributes:t.attributes}})),g=(0,s.lx)(b,(function(e,t){return e.value===t.value}));if(g.length>0)throw new Error('Docusaurus error: Duplicate values "'+g.map((function(e){return e.value})).join(", ")+'" found in <Tabs>. Every value needs to be unique.');var y=null===p?p:null!=(t=null!=p?p:null==(n=h.find((function(e){return e.props.default})))?void 0:n.props.value)?t:null==(l=h[0])?void 0:l.props.value;if(null!==y&&!b.some((function(e){return e.value===y})))throw new Error('Docusaurus error: The <Tabs> has a defaultValue "'+y+'" but none of its children has the corresponding value. Available values are: '+b.map((function(e){return e.value})).join(", ")+". If you intend to show no default tab, use defaultValue={null} instead.");var k=i(),N=k.tabGroupChoices,w=k.setTabGroupChoices,x=(0,a.useState)(y),E=x[0],O=x[1],T=[],j=(0,s.o5)().blockElementScrollPositionUntilNextRender;if(null!=v){var S=N[v];null!=S&&S!==E&&b.some((function(e){return e.value===S}))&&O(S)}var P=function(e){var t=e.currentTarget,n=T.indexOf(t),r=b[n].value;r!==E&&(j(t),O(r),null!=v&&w(v,r))},I=function(e){var t,n=null;switch(e.key){case"ArrowRight":var r=T.indexOf(e.currentTarget)+1;n=T[r]||T[0];break;case"ArrowLeft":var a=T.indexOf(e.currentTarget)-1;n=T[a]||T[T.length-1]}
1null==(t=n)||t.focus()};return a.createElement("div",{className:"tabs-container"},a.createElement("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,u.Z)("tabs",{"tabs--block":d},f)},b.map((function(e){var t=e.value,n=e.label,l=e.attributes;return a.createElement("li",(0,r.Z)({role:"tab",tabIndex:E===t?0:-1,"aria-selected":E===t,key:t,ref:function(e){return T.push(e)},onKeyDown:I,onFocus:P,onClick:P},l,{className:(0,u.Z)("tabs__item",c,null==l?void 0:l.className,{"tabs__item--active":E===t})}),null!=n?n:t)}))),o?(0,a.cloneElement)(h.filter((function(e){return e.props.value===E}))[0],{className:"margin-vert--md"}):a.createElement("div",{className:"margin-vert--md"},h.map((function(e,t){return(0,a.cloneElement)(e,{key:t,hidden:e.props.value!==E})}))))}function p(e){var t=(0,l.Z)();return a.createElement(d,(0,r.Z)({key:String(t)},e))}},136:function(e,t,n){n.r(t),n.d(t,{frontMatter:function(){return u},contentTitle:function(){return c},metadata:function(){return d},toc:function(){return p},default:function(){return v}});var r=n(7462),a=n(3366),l=(n(7294),n(3905)),o=n(6396),i=n(8215),s=["components"],u={sidebar_position:1},c="Getting Started",d={unversionedId:"get-started",id:"get-started",title:"Getting Started",description:"volder is powerful Ob
1ject schema validation, it lets you describe your data using a simple and readable schema and transform a value to match the requirements, it has custom error messages, custom types and nested schemas.",source:"@site/docs/get-started.mdx",sourceDirName:".",slug:"/get-started",permalink:"/docs/next/get-started",editUrl:"https://github.com/devSupporters/volder-doc/tree/main/docs/get-started.mdx",tags:[],version:"current",sidebarPosition:1,frontMatter:{sidebar_position:1},sidebar:"tutorialSidebar",next:{title:"Basic APIs",permalink:"/docs/next/api/basics"}},p=[{value:"Usage",id:"usage",children:[],level:2},{value:"Advantages",id:"advantages",children:[],level:2},{value:"installation",id:"installation",children:[],level:2},{value:"Example",id:"example",children:[],level:2}],m={toc:p};function v(e){var t=e.components,n=(0,a.Z)(e,s);return(0,l.kt)("wrapper",(0,r.Z)({},m,n,{components:t,mdxType:"MDXLayout"}),(0,l.kt)("h1",{id:"getting-started"},"Getting Started"),(0,l.kt)("p",null,(0,l.kt)("strong",{parentName:"p"},"volder")," is powerful Ob
1ject schema validation, it lets you describe your data using a simple and readable schema and transform a value to match the requirements, it has custom error messages, custom types and nested schemas."),(0,l.kt)("hr",null),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("a",{parentName:"li",href:"https://github.com/devSupporters/volder"},(0,l.kt)("strong",{parentName:"a"},"\ud83d\udce6 Volder GitHub Repository"))),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("a",{parentName:"li",href:"'after'"},(0,l.kt)("strong",{parentName:"a"},"\ud83d\udc68\u200d\ud83d\udcbb Try on codesandbox.io"))),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("a",{parentName:"li",href:"./api/basics"},(0,l.kt)("strong",{parentName:"a"},"\ud83d\uddc3\ufe0f API"))),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("a",{parentName:"li",href:"#example"},(0,l.kt)("strong",{parentName:"a"},"\ud83d\uddc2\ufe0f Examples"))),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("a",{parentName:"li",href:"/docs/contributing"},(0,l.kt)("strong",{parentName:"a"},"\ud83d\udcdd Contributing to Volder")),"**")),(0,l.kt)("h2",{id:"usage"},"Usage"),(0,l.kt)("p",null,"You define and create volder schema object. Schema objects are immutable, so each validate call returns a new schema object."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-js"},"import { Volder } from 'volder':\n\nconst personSchema = new Volder({\n name:{ type: String, required: true, maxLength: 10, trim: true },\n age: { type: Number, min: 18, sign: 'positive' }\n})\n\nconst { valid, errors, value } = personSchema({name: \"max \", age: 19});\n// { valid: true, errors: {}, value: {name: \"max\", age: 19}}\n")),(0,l.kt)("h2",{id:"advantages"},"Advantages"),(0,l.kt)("p",null,"This list show you the volder package ",(0,l.kt)("strong",{parentName:"p"},"advantages")," compared with other validation libraries:"),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},"\u2705 ",(0,l.kt)("strong",{parentName:"li"},"Unrequired")," to install other dependency to run volder package."),(0,l.kt)("li",{parentName:"ul"},"\u2705 volder use Maps to validate data, that will improve ",(0,l.kt)("strong",{parentName:"li"},"performance")," and decrease the time."),(0,l.kt)("li",{parentName:"ul"},"\u2705 support ",(0,l.kt)("strong",{parentName:"li"},"Object Schema")," to describe your data.")),(0,l.kt)("h2",{id:"installation"},"installation"),(0,l.kt)(o.Z,{mdxType:"Tabs"},(0,l.kt)(i.Z,{value:"npm",label:"NPM",mdxType:"TabItem"},(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-bash"},"npm install --save volder\n"))),(0,l.kt)(i.Z,{value:"yarn",label:"Yarn",mdxType:"TabItem"},(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-bash"},"yarn add volder\n")))),(0,l.kt)("h2",{id:"example"},"Example"),(0,l.kt)("p",null,"let's took one example using volder for login validation."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-js"},'import { Volder, Email } from "volder";\n\n// initialize using Volder constructor.\nconst userSchema = new Volder({\n username: {\n type: String,\n maxLength: 10,\n // use Custom Error Message feature.\n minLength: [4, "username should be at least 4 characters"],\n default: "guest user",\n },\n email: {\n // Email type imported for volder package, there are other types like UUID.\n type: [Email, "is not valid email"],\n trim: true,\n required: true,\n },\n // you can just Enter the type.\n birth_day: Date,\n password: {\n type: String,\n matches: /^[a-zA-Z0-9]{3,30}$/,\n // pattern config run and return true if value valid otherwise false.\n pattern: [(input) => input.includes("_"), "underscore not included"],\n },\n});\n\nconst validInput = {\n user: "max123",\n email: " [email protected] ",\n birth_day: "1/2/2010",\n password: "new_Password123",\n};\n\nconst { valid, errors, value } = userSchema.validate(validInput);\n// { valid: true, errors: {}, value: {...validInput, email:"[email protected]"}}\n\nconst invalidInput = {\n user: "1",\n email: "test@gmail",\n birth_day: "2010",\n password: "newPassword123",\n};\n\nconst { valid, errors, value } = userSchema.validate(invalidInput);
1\n// {\n// valid: false,\n// errors: {\n// user: "username should be at least 4 characters"\n// email: "is not valid email",\n// password: "underscore not included",\n// birth_day: "birth_day is not valid date, date should be in \'mm/dd/yyyy\' format"\n// },\n// value: {}\n//}\n')))}v.isMDXComponent=!0}}]);
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.