0.1.1 • Published 5 years ago

ow-my-class v0.1.1

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

ow-my-class

Validate a plain object with a class and make it type-safe!

Build Status codecov NPM download Supported by BoostIO

Usage

npm i ow ow-my-class
import Omc from 'ow-my-class'
import ow from 'ow'

class User {
  @Omc(ow.string.minLength(5))
  name: string
}

// Return false
const result = Omc.isValid(
  {
    name: 'yolo'
  },
  User
)

// Throw ValidationError
Omc.validate(
  {
    name: 'yolo'
  },
  User
)

// Transform plain object into User instance
const user = Omc.validate(
  {
    name: 'yolo yolo'
  },
  User
)

License

MIT