minted_contact 1.0.0 copy "minted_contact: ^1.0.0" to clipboard
minted_contact: ^1.0.0 copied to clipboard

Well-modelled Dart value types for contact details: Email and PhoneNumber, checked against the real standards rather than a regex. Part of the minted family.

example/minted_contact_example.dart

// This example prints to stdout so it runs standalone via `dart run`.
// ignore_for_file: avoid_print

import 'package:minted_contact/minted_contact.dart';

void main() {
  // Parse, don't validate: an `Email` exists only if it is well-formed.
  // #region email
  final email = Email.tryParse('Jane.Doe@Example.COM')!;
  print(email.value); // Jane.Doe@example.com  (domain lower-cased)
  print(email.domain); // example.com
  print(email.mailtoUri); // mailto:Jane.Doe@example.com

  print(Email.tryParse('not-an-email')); // null
  // #endregion

  // `PhoneNumber` normalises to E.164. National-format input needs a region
  // `+`-international input does not.
  // #region phone
  final phone = PhoneNumber.tryParse('0 655 5705 76', region: 'FR')!;
  print(phone.value); // +33655570576
  print(phone.type); // PhoneNumberType.mobile
  print(phone.telUri); // tel:+33655570576
  // #endregion
}
0
likes
0
points
59
downloads

Publisher

unverified uploader

Weekly Downloads

Well-modelled Dart value types for contact details: Email and PhoneNumber, checked against the real standards rather than a regex. Part of the minted family.

Homepage
Repository (GitHub)
View/report issues

Topics

#validation #type-safety #email #domain-driven-design #standards

License

unknown (license)

Dependencies

collection, email_validator, minted, minted_network, phone_numbers_parser

More

Packages that depend on minted_contact