https://github.com/matteocrippa/fossil
A typescript validation suite for deno projects
https://github.com/matteocrippa/fossil
deno type-validation typescript validation validator value-validation
Last synced: about 1 month ago
JSON representation
A typescript validation suite for deno projects
- Host: GitHub
- URL: https://github.com/matteocrippa/fossil
- Owner: matteocrippa
- License: mit
- Created: 2020-05-24T11:26:59.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-06-22T14:54:43.000Z (over 5 years ago)
- Last Synced: 2024-08-03T03:06:34.518Z (over 1 year ago)
- Topics: deno, type-validation, typescript, validation, validator, value-validation
- Language: TypeScript
- Size: 18.6 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-deno - fossil - A value-type validation suite. (Modules / Utils)
- awesome-deno-cn - @matteocrippa/fossil
README
#  fossil
A typescript validation suite for deno projects.
At this _alpha_ stage fossil support validation for the following types:
- [x] String
- [x] Number
- [x] Symbol
- [x] Custom function
- [x] Array
- [x] Object
- [x] Null
- [x] Undefined
- [x] Email
- [ ] Alphanumeric
A good companion project for `fossil` is [Microraptor](https://github.com/matteocrippa/microraptor) a lightweight framework for easy routing.
## Install
Import _fossil_ in your project with just one line of code:
```ts
import { Validator } from "https://deno.land/x/fossil/fossil.ts";
```
## How to use
### Check type
```ts
let testBoolean = new Validator(true, ValidatorType.boolean);
console.log(testBoolean.isValid()); // true
testBoolean = new Validator("home", ValidatorType.boolean);
console.log(testBoolean.isValid()); // Invalid type
```
For more use feel free to check test examples.
### Check type and value
```ts
let testBoolean = new Validator(true, ValidatorType.boolean, [true]);
console.log(testBoolean.isValid()); // true
```
## Extra
_Credits_
Icon made by [Freepik](https://www.flaticon.com/authors/freepik) from [www.flaticon.com](https://www.flaticon.com/)