Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 28 days 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 (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-06-22T14:54:43.000Z (over 4 years ago)
- Last Synced: 2024-08-03T03:06:34.518Z (4 months 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 Logo](https://raw.githubusercontent.com/matteocrippa/fossil/master/.github/footprint.png) 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
- [ ] AlphanumericA 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()); // truetestBoolean = 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/)