zod_validation 1.0.5 copy "zod_validation: ^1.0.5" to clipboard
zod_validation: ^1.0.5 copied to clipboard

This is a package for validating data.

example/zod_validation_example.dart

import 'package:zod_validation/zod_validation.dart';

void main() {
  final params = {
    'user': {
      'platform': Zod().required(),
      'data': {
        'id': Zod().type<int>(),
        'name': Zod().min(3).max(10),
        'email': Zod().email(),
        'phone': Zod().optional(isValidWhenEmpty: false).phone(),
      },
    }
  };

  /// the received params from the request
  final requestParams = <String, dynamic>{
    'user': {
      'platform': 'web',
      'data': {
        'id': 1,
        'name': 'John Doe',
        'email': 'welito@gmail.com',
        'phone': '',
      }
    }
  };

  final result = Zod.validate(params: params, data: requestParams);
  if (result.isNotValid) print(result.result);
  if (result.isValid) print('Valid');
}
15
likes
150
pub points
65%
popularity

Publisher

unverified uploader

This is a package for validating data.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

More

Packages that depend on zod_validation