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

A lightweight, dependency-free Dart package that adds fluent String validation extension methods for emails, passwords, URLs, phone numbers, dates, UUIDs, IP addresses, credit cards, and more.

example/main.dart

// ignore_for_file: avoid_print
import 'package:clean_string_validator/clean_string_validator.dart';

void main() {
  // Email
  print('john@gmail.com'.isValidEmail); // true

  // Password
  print('Password@123'.isStrongPassword); // true

  // Phone
  print('+923001234567'.isValidPhone); // true
  print('03001234567'.isValidPhone); // true

  // URL
  print('https://flutter.dev'.isValidUrl); // true

  // Username
  print('john_doe123'.isValidUsername); // true

  // Numbers
  print('123'.isNumeric); // true
  print('42'.isInteger); // true
  print('42.5'.isDouble); // true
  print('10'.isPositiveNumber); // true
  print('-10'.isNegativeNumber); // true

  // Date
  print('2024-05-10'.isValidDate); // true

  // JSON
  print('{"name":"John"}'.isJson); // true

  // UUID
  print('123e4567-e89b-12d3-a456-426614174000'.isUUID); // true

  // IP / MAC
  print('192.168.0.1'.isIPv4); // true
  print('2001:0db8:85a3:0000:0000:8a2e:0370:7334'.isIPv6); // true
  print('00:1B:44:11:3A:B7'.isMacAddress); // true

  // Hex color
  print('#ffffff'.isHexColor); // true

  // Credit card
  print('4539578763621486'.isValidCreditCard); // true

  // Text helpers
  print('   '.isBlank); // true
  print('hello'.hasText); // true
  print('Hello'.containsUppercase); // true
  print('hello'.containsLowercase); // true
  print('hello1'.containsNumber); // true
  print('hello!'.containsSpecialCharacter); // true
  print('hello'.containsOnlyLetters); // true
  print('12345'.containsOnlyDigits); // true
  print('hello'.isAlphabet); // true
  print('hello123'.isAlphaNumeric); // true
  print('hello'.hasMinLength(3)); // true
  print('hello'.hasMaxLength(10)); // true
  print('hello'.hasExactLength(5)); // true
  print('HELLO'.isUpperCase); // true
  print('hello'.isLowerCase); // true
  print('Hello World'.isTitleCase); // true
}
2
likes
150
points
37
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A lightweight, dependency-free Dart package that adds fluent String validation extension methods for emails, passwords, URLs, phone numbers, dates, UUIDs, IP addresses, credit cards, and more.

Repository (GitHub)
View/report issues

Topics

#validation #string #extensions #form

License

MIT (license)

More

Packages that depend on clean_string_validator