https://github.com/boostio/ow-my-class
Validate a plain object with a class and make it type-safe!
https://github.com/boostio/ow-my-class
ow typescript validator
Last synced: 22 days ago
JSON representation
Validate a plain object with a class and make it type-safe!
- Host: GitHub
- URL: https://github.com/boostio/ow-my-class
- Owner: BoostIO
- Created: 2019-05-31T00:38:45.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-05-31T08:01:20.000Z (almost 6 years ago)
- Last Synced: 2025-05-07T17:13:49.079Z (22 days ago)
- Topics: ow, typescript, validator
- Language: TypeScript
- Size: 14.6 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# `ow-my-class`
Validate a plain object with a class and make it type-safe!
[](https://travis-ci.com/BoostIO/ow-my-class)
[](https://codecov.io/gh/BoostIO/ow-my-class)
[](https://www.npmjs.com/package/prismy)
[](https://boostio.co)## Usage
```sh
npm i ow ow-my-class
``````ts
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