@serum-enterprises/schema 2.0.1-beta.2 → 3.0.0-beta.1

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.
package/README.md CHANGED
@@ -5,40 +5,30 @@ Modern Schema Validation Library inspired by Joi.dev
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- npm install --save @serum-enterprises/schema
8
+ npm install --save @serum-enterprises/schema@3.0.0-beta.1
9
9
  ```
10
10
 
11
11
  ## Usage
12
12
 
13
13
  ```typescript
14
- import Schema from '@serum-enterprises/schema';
15
-
16
- const schema = Schema.Object
17
- .nullable()
18
- .schema({
19
- name: Schema.String,
20
- age: Schema.Number.integer().min(18).max(99),
21
- friends: Schema.Array
22
- .every(
23
- Schema.Or.oneOf([
24
- Schema.Object
25
- .schema({
26
- name: Schema.String,
27
- age: Schema.Number.min(18).max(99)
28
- }),
29
- Schema.String
30
- ])
31
- )
32
- });
33
-
34
- schema.validate({ name: 'John', age: 20, friends: [{ name: "Maria", age: 22 }] });
35
- ```
14
+ import {Schema} from '@serum-enterprises/schema';
15
+
16
+ const schema = Schema.Object.nullable().shape({
17
+ name: Schema.String,
18
+ age: Schema.Number.integer().min(18).max(99),
19
+ friends: Schema.Array.every(Schema.String)
20
+ }).exact();
36
21
 
37
- **Note: Schema.fromJSON and Schema.validate return a Result. See @serum-enterprises/result for more Information.**
22
+ const person = schema.validate({name: 'John', age: 20, friends: ["Jane", "Mary"]});
23
+
24
+ console.log(person.name);
25
+ console.log(person.age);
26
+ console.log(person.friends.join(', '));
27
+ ```
38
28
 
39
29
  ## API
40
30
 
41
- Please check [Schema.d.ts](./types/Schema.d.ts) for the full API.
31
+ Please check [index.d.ts](./types/index.d.ts) for the full API.
42
32
 
43
33
  ## LICENSE
44
34