1.5.0 • Published 2 years ago

record-validator v1.5.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Record Validator

Record validator is a NodeJS package that allows you to do a runtime check of a given Record.

How to use it

import { TypeValidator } from "record-validator"

interface ISimpleTest {
  id: number,
  name: string,
}


const validator = new TypeValidator<ISimpleTest>({
  id: {
    required: true,
    type: "number"
  },
  name: {
    required: true,
    type: "string"
  }
})

const value = {
  id: 12,
  name: "toto"
}

validator.test(value)
// Returns null on success and a string explaining the error on failure.

You should check the unit tests to know more about this package, including how to implement custom validators for your types and nested fields.

1.5.0

2 years ago

1.4.0

2 years ago

1.3.0

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago