Skip to content

Commit

Permalink
docs: add minimal skeleton for gitbook
Browse files Browse the repository at this point in the history
  • Loading branch information
NoNameProvided committed Apr 25, 2018
1 parent b1e1bb5 commit ee81c0a
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitbook.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
root: docs
structure:
readme: README.md
summary: docs/README.md
38 changes: 38 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Table of Contents

* [Read Me](../README.md)
* Getting Started
* [Installation](introduction/installation.md)
* [Usage with Typescript](introduction/usage-with-typescript.md)
* [Usage with Javascript](introduction/usage-with-javascript.md)
* [Dependency Injection](introduction/usage-with-di.md)
* [Core Principes](introduction/core-principes.md)
* [Basic Usage](basics/README.md)
* [Validating objects](basics/validating-objects.md)
* [Validating arrays](basics/validating-arrays.md)
* [Validating nested objects](basics/validating-nested-objects.md)
* [Advanced Usage](advanced/README.md)
* [Conditional Validation](advanced/conditional-validation.md)
* [Validation Groups](advanced/validation-groups.md)
* [Inheritance](advanced/inheritance.md)
* [Custom Validation Decorators](advanced/validations-decoratos.md)
* [Custom Validation Classes](advanced/validation-classes.md)
* [Decorators Reference](reference/decoratos.md)
* [Common Decorators](reference/common-decoratos.md)
* [Number Decorators](reference/number-decoratos.md)
* [String Decorators](reference/string-decoratos.md)
* [Date Decorators](reference/date-decoratos.md)
* [Array Decorators](reference/array-decoratos.md)
* [Recipes](recipes/README.md)
* [Simple Validations](https://stackblitz.com/edit/class-transformer-simple-validations)
* [Nested Objects](https://stackblitz.com/edit/class-transformer-nested-objects)
* [Using Groups](https://stackblitz.com/edit/class-transformer-using-groups)
* [Custom Validators](https://stackblitz.com/edit/class-transformer-custom-validator)
* [Custom Decorators](https://stackblitz.com/edit/class-transformer-custom-decorators)
* [Using Schemas](https://stackblitz.com/edit/class-transformer-schemas)
* [Inheritance](https://stackblitz.com/edit/class-transformer-inheritance)
* [API Reference](api/README.md)
* [validate](api/validate.md)
* [ValidatorOptions ](api/ValidatorOptions.md)
* [ValidationError ](api/ValidationError.md)
* [Change Log](../CHANGELOG.md)
40 changes: 40 additions & 0 deletions docs/basics/validating-objects.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Validating objects

```ts
import { validate, IsString, IsInt, IsDate, MaxLength, Min, Max} from "class-validator";

export class Book {

@IsString()
@MaxLength(255)
title: string;

@IsString()
@MaxLength(255)
author: string;

@IsInt()
@Min(0)
@Max(10)
rating: number;

@IsDate()
publishDate: Date;

}

const book = new Book();
post.title = 'Don Quixote';
post.author = 'Miguel De Cervantes';
post.rating = 11;
post.publishDate = 1615;

validate(book).then(errors => {
// errors is an array of ValidationErrors
if (errors.length > 0) {
console.warn("validation failed. errors: ", errors);
}
});
```

Run this example on [Stackblitz](https://stackblitz.com/edit/class-validator-simple-example)
21 changes: 21 additions & 0 deletions docs/introduction/installation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Installation

To install the stable version:

```
npm install --save class-validator
```

### Usage in the browser

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.

### Next version

You can install the next version of `class-validator` via

```
npm install --save class-validator@next
```

> Note: The next version can break anytime without notice. Do not use this in production.

0 comments on commit ee81c0a

Please sign in to comment.