shelf_dto 0.1.2 copy "shelf_dto: ^0.1.2" to clipboard
shelf_dto: ^0.1.2 copied to clipboard

A simple dto builder for dart, use annotations and code gen to create simple and complete DTO for your project.

example/main.dart

import 'package:shelf_dto/shelf_dto.dart';

import 'dto/user_dto.dart';

// Main function to example the Example folder
void main() {
  final userDTO = UserDTOValidator.fromMap({
    'name': 'heron',
    'age': 30,
  });

  try {
    userDTO.validate();

    String name = userDTO.name;
    int age = userDTO.age;
    print('Name: $name, Age: $age');
  } on DTOException catch (e) {
    print(e.errors);
  }

  final userDTO2 = UserDTOValidator.fromMap({
    'name': null,
    'age': 30,
  });

  try {
    userDTO2.validate();
  } on DTOException catch (e) {
    print(e.errors);
  }
}
3
likes
0
points
2
downloads

Publisher

verified publisherorcatech.site

Weekly Downloads

A simple dto builder for dart, use annotations and code gen to create simple and complete DTO for your project.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

analyzer, build, build_runner, source_gen

More

Packages that depend on shelf_dto