Skip to content

Commit ee81c0a

Browse files
docs: add minimal skeleton for gitbook
1 parent b1e1bb5 commit ee81c0a

File tree

4 files changed

+103
-0
lines changed

4 files changed

+103
-0
lines changed

.gitbook.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
root: docs
2+
structure:
3+
readme: README.md
4+
summary: docs/README.md

docs/README.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Table of Contents
2+
3+
* [Read Me](../README.md)
4+
* Getting Started
5+
* [Installation](introduction/installation.md)
6+
* [Usage with Typescript](introduction/usage-with-typescript.md)
7+
* [Usage with Javascript](introduction/usage-with-javascript.md)
8+
* [Dependency Injection](introduction/usage-with-di.md)
9+
* [Core Principes](introduction/core-principes.md)
10+
* [Basic Usage](basics/README.md)
11+
* [Validating objects](basics/validating-objects.md)
12+
* [Validating arrays](basics/validating-arrays.md)
13+
* [Validating nested objects](basics/validating-nested-objects.md)
14+
* [Advanced Usage](advanced/README.md)
15+
* [Conditional Validation](advanced/conditional-validation.md)
16+
* [Validation Groups](advanced/validation-groups.md)
17+
* [Inheritance](advanced/inheritance.md)
18+
* [Custom Validation Decorators](advanced/validations-decoratos.md)
19+
* [Custom Validation Classes](advanced/validation-classes.md)
20+
* [Decorators Reference](reference/decoratos.md)
21+
* [Common Decorators](reference/common-decoratos.md)
22+
* [Number Decorators](reference/number-decoratos.md)
23+
* [String Decorators](reference/string-decoratos.md)
24+
* [Date Decorators](reference/date-decoratos.md)
25+
* [Array Decorators](reference/array-decoratos.md)
26+
* [Recipes](recipes/README.md)
27+
* [Simple Validations](https://stackblitz.com/edit/class-transformer-simple-validations)
28+
* [Nested Objects](https://stackblitz.com/edit/class-transformer-nested-objects)
29+
* [Using Groups](https://stackblitz.com/edit/class-transformer-using-groups)
30+
* [Custom Validators](https://stackblitz.com/edit/class-transformer-custom-validator)
31+
* [Custom Decorators](https://stackblitz.com/edit/class-transformer-custom-decorators)
32+
* [Using Schemas](https://stackblitz.com/edit/class-transformer-schemas)
33+
* [Inheritance](https://stackblitz.com/edit/class-transformer-inheritance)
34+
* [API Reference](api/README.md)
35+
* [validate](api/validate.md)
36+
* [ValidatorOptions ](api/ValidatorOptions.md)
37+
* [ValidationError ](api/ValidationError.md)
38+
* [Change Log](../CHANGELOG.md)

docs/basics/validating-objects.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Validating objects
2+
3+
```ts
4+
import { validate, IsString, IsInt, IsDate, MaxLength, Min, Max} from "class-validator";
5+
6+
export class Book {
7+
8+
@IsString()
9+
@MaxLength(255)
10+
title: string;
11+
12+
@IsString()
13+
@MaxLength(255)
14+
author: string;
15+
16+
@IsInt()
17+
@Min(0)
18+
@Max(10)
19+
rating: number;
20+
21+
@IsDate()
22+
publishDate: Date;
23+
24+
}
25+
26+
const book = new Book();
27+
post.title = 'Don Quixote';
28+
post.author = 'Miguel De Cervantes';
29+
post.rating = 11;
30+
post.publishDate = 1615;
31+
32+
validate(book).then(errors => {
33+
// errors is an array of ValidationErrors
34+
if (errors.length > 0) {
35+
console.warn("validation failed. errors: ", errors);
36+
}
37+
});
38+
```
39+
40+
Run this example on [Stackblitz](https://stackblitz.com/edit/class-validator-simple-example)

docs/introduction/installation.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Installation
2+
3+
To install the stable version:
4+
5+
```
6+
npm install --save class-validator
7+
```
8+
9+
### Usage in the browser
10+
11+
If you want to use `class-validator` in the browser and you use Webpack then just import it into your project and Webpack will take care of the rest.
12+
13+
### Next version
14+
15+
You can install the next version of `class-validator` via
16+
17+
```
18+
npm install --save class-validator@next
19+
```
20+
21+
> Note: The next version can break anytime without notice. Do not use this in production.

0 commit comments

Comments
 (0)