valid-data

validate JSON by own structure

Usage no npm install needed!

<script type="module">
  import validData from 'https://cdn.skypack.dev/valid-data';
</script>

README

Usage

const data = {
  a: 1,
  array: [{ a: 1 }]
};

const valid = new ValidGroup({
  a: {
    validFun: function(value) {
      return value === 1;
    }
  },
  array: new ValidArray({
    a: {
      validFun: function(value) {
        return value === 1;
      }
    }
  })
});
valid.do(data);

use valid.valid to get the result(true | false);