Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/makhosi6/rsa_id_number
A Dart package for validating and generating South African ID numbers.
https://github.com/makhosi6/rsa_id_number
dart dart-lang dart-package flutter identity-number south-africa south-african-id
Last synced: 3 months ago
JSON representation
A Dart package for validating and generating South African ID numbers.
- Host: GitHub
- URL: https://github.com/makhosi6/rsa_id_number
- Owner: makhosi6
- License: mit
- Created: 2024-01-07T14:34:08.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-08-13T13:21:12.000Z (5 months ago)
- Last Synced: 2024-09-29T16:04:03.622Z (3 months ago)
- Topics: dart, dart-lang, dart-package, flutter, identity-number, south-africa, south-african-id
- Language: HTML
- Homepage: https://pub.dev/packages/rsa_id_number
- Size: 140 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# rsa_id_number
A Dart package for validating and generating South African ID numbers.
## Features
- **Validation**: Validate South African ID numbers based on the specified [format](https://en.wikipedia.org/wiki/South_African_identity_card).
- **Generation**: Generate random South African ID numbers.
- **Parser**: Parse string(ID numbers) to Object## Installation
Add the following line to your `pubspec.yaml` file:
```yaml
dependencies:
rsa_id_number:
```Then run:
```bash
$ pub get
```or
```bash
$ flutter pub get
```## Usage
### Validation
```dart
import 'package:rsa_id_number/rsa_id_validator.dart';void main() {
String idToValidate = '9202204720082';
bool isValid = RsaIdValidator.isValid(idToValidate);
print('Is valid ID: $isValid');
}
```### Generation
```dart
import 'package:rsa_id_number/rsa_id_generator.dart';void main() {
/// generate a random/valid SA id number
final rsaIdNumber = RsaIdGenerator.generate();
log('Generated ID: $rsaIdNumber');/// generate with options
final rsaIdNumber2 = RsaIdGenerator.generate(
gender: Gender.FEMALE,
citizenship: Citizenship.CITIZEN_BORN,
maxDate: DateTime(1969),
minDate: DateTime.now(),
);
log('Generated ID: $rsaIdNumber2');
}
```### Parser
```dart
import 'package:rsa_id_number/rsa_id_generator.dart';void main() {
String idNumber = "8801235121088";
RsaIdParser parser = RsaIdParser.parse(idNumber);print('Date of Birth: ${parser.dateOfBirth}');
print('Gender: ${parser.sex}');
print('Citizenship: ${parser.citizenship}');
print('Race: ${parser.race}');
print('Is Valid: ${parser.isValid}');
}
```## Contributing
Feel free to [contribute](./CONTRIBUTE.md) to this project by submitting issues and pull requests.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.