@local901/validator 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +29 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # js-validator
2
+
3
+ Validator for javascript and typescript. Do you have an object with uncertain contents. USe a validator to make sure what you have.
4
+
5
+ Quick start:
6
+ ```shell
7
+ npm install @local901/validator
8
+ ```
9
+
10
+ Example:
11
+
12
+ ```typescript
13
+ import { v } from "@local901/validator";
14
+
15
+ type Example = {
16
+ message: string;
17
+ isPublic?: boolean;
18
+ }
19
+
20
+ const validator = v.object<Example>({
21
+ message: v.string({ min: 6 }),
22
+ isPublic: v.optional(v.boolean()),
23
+ });
24
+
25
+ validator.validate({ message: "example" }) // returns true
26
+ validator.validate({ message: "short" }) // returns false
27
+
28
+ validator.validateOrThrow(15) // throws error.
29
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@local901/validator",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "Type validator for javascript and typescript",
5
5
  "main": "index.js",
6
6
  "scripts": {