Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/shindakioku/dto_validator


https://github.com/shindakioku/dto_validator

Last synced: 5 days ago
JSON representation

Awesome Lists containing this project

README

        

# dto_validator

A library for Dart backend developers.

Created from templates made available by Stagehand under a BSD-style
[license](https://github.com/dart-lang/stagehand/blob/master/LICENSE).

## Usage

A simple usage example:

import 'package:validator/validator.dart';

class User {
@Rules(min: 5)
String email;

@Rules(required: true, min: 5)
int id;

@Rules(required: true)
String phone;
}

void main() async {
var validator = new Validator();
var user = new User()
..email = '[email protected]'
..id = 2
..phone = '123123';

var errors = await validator.validate(user);
// {User.id: Cannot be less than 5}
print(errors);
}

For more examples see -

`/examples`

## Tests
Run in console(from root directory)

`pub run test test .`