-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update docs, remove unused pkgs, version bump: v1.0.1
- Loading branch information
Showing
11 changed files
with
208 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,38 @@ | ||
# rsa_id_number Change Log | ||
|
||
All notable changes to this project will be documented in this file. All changes/updates/entries are not 'breaking changes' unless otherwise mentioned. | ||
This project adheres to [Semantic Versioning](http://semver.org/). | ||
This project adheres to [Semantic Versioning](https://semver.org/). | ||
|
||
## 0.0.1 - 2024-01-07 | ||
|
||
- initial draft | ||
|
||
## 0.0.2 - 2024-01-07 | ||
|
||
- publish with updated description & metadata | ||
- publish with updated description & metadata | ||
|
||
## 0.1.5 - 2024-01-08 | ||
|
||
- fix linter errors and update analysis rules | ||
|
||
## 0.1.6 - 2024-01-08 | ||
|
||
- update the readme file | ||
|
||
## 0.1.7 - 2024-01-09 | ||
|
||
- 'intl': always use the latest version | ||
|
||
## 0.1.8 - 2024-01-11 | ||
|
||
- implement pub.dev recommendations, [see more](https://github.com/makhosi6/rsa_id_number/pull/9) | ||
|
||
## [Complete] 1.0.0 - 2024-06-01 | ||
|
||
### Added | ||
- last and final module to parse id(string) to object | ||
- the package is feature complete, it has all intended functionality(create, validate and parse rsa IDs) | ||
|
||
## 1.0.1 - 2024-06-01 | ||
|
||
- update the docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,33 @@ | ||
import '../helpers/rsa_id_utils.dart'; | ||
import 'package:rsa_id_number/helpers/rsa_id_utils.dart'; | ||
|
||
/// Generates random valid South African ID numbers or creates new ones based on specified rules. | ||
class RsaIdGenerator { | ||
/// Generates a random valid South African ID number. | ||
/// | ||
/// - [gender] parameter specifies the gender ('female' or 'male'). | ||
/// - [citizenship] parameter specifies the citizenship ('citizen' or 'resident'). | ||
/// - [maxDate] and [minDate] parameters define the date range for generating the birthdate. | ||
/// - maxDate default value is `DateTime(1920)` | ||
/// - minDate default value is `DateTime.now()` | ||
/// Returns a randomly generated valid ID number. | ||
static String generate({ | ||
Gender? gender, | ||
Citizenship? citizenship, | ||
DateTime? maxDate, | ||
DateTime? minDate, | ||
}) { | ||
String date = RsaIdUtils.generateDate(maxDate: maxDate, minDate: minDate); | ||
String genderCode = RsaIdUtils.generateGender(gender); | ||
String citizenshipCode = RsaIdUtils.generateCitizenship(citizenship); | ||
int raceDeprecated = 8; | ||
|
||
String luhnNr = RsaIdUtils.luhnAppend( | ||
"$date$genderCode$citizenshipCode$raceDeprecated"); | ||
// Generate a random birthdate within the specified date range. | ||
final date = RsaIdUtils.generateDate(maxDate: maxDate, minDate: minDate); | ||
// Generate gender codes. | ||
final genderCode = RsaIdUtils.generateGender(gender); | ||
// Generate citizenship codes. | ||
final citizenshipCode = RsaIdUtils.generateCitizenship(citizenship); | ||
// Specify the race code (deprecated). | ||
const raceDeprecated = 8; | ||
// Calculate the checksum digit and construct the final ID number. | ||
final luhnNr = RsaIdUtils.luhnAppend( | ||
"$date$genderCode$citizenshipCode$raceDeprecated", | ||
); | ||
return luhnNr; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.