{
  "template": [
    "2iyza7uskm7vo9oe",
    "2iyza2twkmh5brt6",
    "2iyza2twkmh5cuqa",
    "2iyza2twkmh5d8q2",
    "2iyza2twkmh5dl89",
    "2iyza2twkmh5e16q"
  ],
  "rows": {
    "2iyza7uskm7vo9oe": {
      "id": "2iyza7uskm7vo9oe",
      "template": [
        "2iyza7uskm7voaxa",
        "2iyza7uskm7vock6",
        "2iyza7uskm7vocvq"
      ],
      "containers": {
        "2iyza7uskm7voaxa": {
          "id": "2iyza7uskm7voaxa",
          "field": {
            "type": "heading",
            "data": {
              "value": "engine.validate.json api"
            }
          }
        },
        "2iyza7uskm7vock6": {
          "id": "2iyza7uskm7vock6",
          "field": {
            "type": "paragraph",
            "data": {
              "value": "this api checks a json object against a given data structure."
            }
          }
        },
        "2iyza7uskm7vocvq": {
          "id": "2iyza7uskm7vocvq",
          "field": {
            "type": "code",
            "data": {
              "value": "\n//==================================\n//api arguments\n//==================================\n/*\n\n\t//----------------\n    \n\tengine.validate.json(\n    \tschema_object,\n        data_object,\n        data_object_size_limit,\n        max_num_of_keys_in_data,\n        return_error_boolean\n    );\n    \n    //----------------\n    \n    1. schema_object is a native object to match the data\n    \n    2. data_object is obvious data to check,\n    \n    3. data_object_size_limit the size of the data might is diffrent with each request so there are 2 checks \"dynamic\" and \"static\"\n    \n    \t-default is static\n        \n        -static check matches all the key any missing or addional keys will fail the test\n        \n        -dynamic will only ignore the keys that are marked elective if they are not present in data.\n        \n    4. max_num_of_keys_in_data is obvios max number of keys in the data object \n    \n    5. turn_error_boolean default the validate api returns false boolean but if a error stringis needed this boolean can be set to true to get it on error.\n    \n*/\n\n//==================================\n//static validation\n//==================================\n\nconst static_object = {\n\taccount_type:'admin',\n\tname:\"akku\",\n    id:12,\n    email:'gzbakku@gmail.com',\n    token:{\n    \ttime:456456446545,\n        id:'ds9898989898'\n    }\n};\n\nconst static_schema = {\n\taccount_type:{type:'string',options:['admin','user']},\n\tname:{type:'string',min:3,max:256},\n    id:{type:'number',min:1,max:256},\n    email:{type:'email',min:3,max:256},\n    token:{type:'object',validate:{\n    \tschema:{\n        \ttime:{type:'number',max:45645644654523},\n            id:{type:'string',max:256}\n        },\n        dynamic:false,\n        maxSize:2\n    }},\n};\n\nconst static_validate = engine.validate.json(static_schema,static_object);\n\nconsole.log({static_validate:static_validate});\n\n//==================================\n//\tdynamic validation\n//==================================\n\nconst dynamic_object = {\n\tis_admin:true,\n\tname:\"akku\",\n    id:12\n};\n\nconst dynamic_schema = {\n\tis_admin:{type:'boolean'},\n    name:{type:'string'},\n    id:{type:'number'},\n    email:{type:'email',elective:true},\n    token:{type:'object',elective:true}\n};\n\nconst dynamic_validate = engine.validate.json(dynamic_schema,dynamic_object,\"dynamic\",5);\n\nconsole.log({dynamic_validate:dynamic_validate});\n\n//==================================\n//\tfail case\n//==================================\n\nconst fail_object = {\n\tis_admin:true,\n\tname:\"akku\"\n};\n\nconst fail_schema = {\n\tis_admin:{type:'boolean'},\n    name:{type:'string'},\n    id:{type:'number'}\n};\n\nconst fail_validate = engine.validate.json(fail_schema,fail_object,\"static\",3,true);\n\nconsole.log({fail_validate:fail_validate});\n"
            }
          }
        }
      }
    },
    "2iyza2twkmh5brt6": {
      "id": "2iyza2twkmh5brt6",
      "template": [
        "2iyza2twkmh5btk2",
        "2iyza2twkmh5byjm"
      ],
      "containers": {
        "2iyza2twkmh5btk2": {
          "id": "2iyza2twkmh5btk2",
          "field": {
            "type": "heading",
            "data": {
              "value": "type validation parameter"
            }
          }
        },
        "2iyza2twkmh5byjm": {
          "id": "2iyza2twkmh5byjm",
          "field": {
            "type": "paragraph",
            "data": {
              "value": "1 string\n2 number\n3 object\n4 email\n5 array\n\ntype param takes the given options as a value and check the data type of be the exact same for the given value in data to be validated\n\nSpecial Functions\n\n1 String Field\n\n\tstring field can check value against a array of string any value not in the array will fail. \n\n2 Object Field\n\t\n    Object Fields can validate the value of object against a validate object\n    \n    {\n    \tshchema:schema_object,\n        maxSize:max_num_of_keys_in_data,\n        dynamic:boolean,\n        returnError:boolean\n    }"
            }
          }
        }
      }
    },
    "2iyza2twkmh5cuqa": {
      "id": "2iyza2twkmh5cuqa",
      "template": [
        "2iyza2twkmh5cwld",
        "2iyza2twkmh5cwzd"
      ],
      "containers": {
        "2iyza2twkmh5cwld": {
          "id": "2iyza2twkmh5cwld",
          "field": {
            "type": "heading",
            "data": {
              "value": "Min validation parameter"
            }
          }
        },
        "2iyza2twkmh5cwzd": {
          "id": "2iyza2twkmh5cwzd",
          "field": {
            "type": "paragraph",
            "data": {
              "value": "min parameter check the string,array,number or object keys length to be equal or higher to the number given as a value to this parameter in the schema to be the same of that given in the data to be validated. caution :- for any given number the validation checks if the number is less or equal to the given number not the length of the number.\n\ncaution :- for any given number the validation checks if the number is less or equal to the given number not the length of the number."
            }
          }
        }
      }
    },
    "2iyza2twkmh5d8q2": {
      "id": "2iyza2twkmh5d8q2",
      "template": [
        "2iyza2twkmh5d9pd",
        "2iyza2twkmh5da81"
      ],
      "containers": {
        "2iyza2twkmh5d9pd": {
          "id": "2iyza2twkmh5d9pd",
          "field": {
            "type": "heading",
            "data": {
              "value": "Max validation parameter"
            }
          }
        },
        "2iyza2twkmh5da81": {
          "id": "2iyza2twkmh5da81",
          "field": {
            "type": "paragraph",
            "data": {
              "value": "max parameter check the string,array,number or object keys length to be equal or lower to the number given as a value to this parameter in the schema to be the same of that given in the data to be validated."
            }
          }
        }
      }
    },
    "2iyza2twkmh5dl89": {
      "id": "2iyza2twkmh5dl89",
      "template": [
        "2iyza2twkmh5dnqq",
        "2iyza2twkmh5dsex"
      ],
      "containers": {
        "2iyza2twkmh5dnqq": {
          "id": "2iyza2twkmh5dnqq",
          "field": {
            "type": "heading",
            "data": {
              "value": "Options validation parameter"
            }
          }
        },
        "2iyza2twkmh5dsex": {
          "id": "2iyza2twkmh5dsex",
          "field": {
            "type": "paragraph",
            "data": {
              "value": "options parametere can only be given to the string data type and it checks if the given value in the data is present in the array provided in the schema."
            }
          }
        }
      }
    },
    "2iyza2twkmh5e16q": {
      "id": "2iyza2twkmh5e16q",
      "template": [
        "2iyza2twkmh5e21t",
        "2iyza2twkmh5e2cx"
      ],
      "containers": {
        "2iyza2twkmh5e21t": {
          "id": "2iyza2twkmh5e21t",
          "field": {
            "type": "heading",
            "data": {
              "value": "elective validation parameter"
            }
          }
        },
        "2iyza2twkmh5e2cx": {
          "id": "2iyza2twkmh5e2cx",
          "field": {
            "type": "paragraph",
            "data": {
              "value": "this parametere if given as true ingnores if the data is not present in the data to be validated."
            }
          }
        }
      }
    }
  },
  "title": "Vegana Api : Engine Validate Json Api",
  "discription": "this api checks a json object against a given data structure.",
  "keywords": "vegana,api,engine,validate,json,schema,body,structure"
}