Skip to content

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

Notifications You must be signed in to change notification settings

BoostIO/ow-my-class

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
)

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

License

MIT

About

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

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published