pesel_validator 0.1.0 pesel_validator: ^0.1.0 copied to clipboard
Dart package for PESEL number validation
Pesel Validator #
A dart package for PESEL number validation
Features: #
- Check if given PESEL number is valid
- Extract gender from PESEL
- Extract date of birth from PESEL
- Extract age from PESEL
Installation 💻 #
❗ In order to start using Pesel Validator you must have the Dart SDK installed on your machine.
Add pesel_validator
to your pubspec.yaml
:
dependencies:
pesel_validator: 0.1.0
Install it:
dart pub get
Example #
See example/example.dart
import 'package:pesel_validator/pesel_validator.dart';
void main() {
const validPesel = '92071314764';
const invalidPesel = '00000000000';
// pesel number validation
validatePesel(pesel: validPesel); // true
validatePesel(pesel: invalidPesel); // false
// sex from pesel number
sexFromPesel(pesel: validPesel); // Sex.woman
// sexFromPesel(pesel: invalidPesel); // throws InvalidPeselException
// date of birth from pesel
dateOfBirthFromPesel(pesel: validPesel); // DateTime (13.07.1992)
// dateOfBirthFromPesel(pesel: invalidPesel); // throws InvalidPeselException
// age from pesel
ageFromPesel(pesel: validPesel); // int age value
// ageFromPesel(pesel: invalidPesel); // throws InvalidPeselException
}