diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ca4c69..7859dd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,4 +40,7 @@ - tests update -> 100% coverage ## 3.0.1 -- README update \ No newline at end of file +- README update + +## 3.0.2 +- Add a method to validate a specific menmonic word \ No newline at end of file diff --git a/lib/src/language.dart b/lib/src/language.dart index 205af2e..6fe06fd 100644 --- a/lib/src/language.dart +++ b/lib/src/language.dart @@ -38,4 +38,9 @@ enum Language { return '\u{0020}'; // space (SP) } } + + /// isValid checks the provided word presence in the wordlist + bool isValid(String word) { + return list.contains(word); + } } diff --git a/pubspec.yaml b/pubspec.yaml index a3baa3d..d4210ab 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,14 +1,14 @@ name: bip39_mnemonic description: Mnemonic code for generating deterministic keys a.k.a. BIP39. -version: 3.0.1 +version: 3.0.2 homepage: https://github.com/ethicnology/dart-bip39-mnemonic environment: sdk: '>=2.17.0 <3.0.0' dev_dependencies: lints: ^2.0.0 - test: ^1.21.1 - convert: ^3.0.1 + test: ^1.21.3 + convert: ^3.0.2 dependencies: pointycastle: ^3.6.0 unorm_dart: ^0.2.0 diff --git a/test/language_test.dart b/test/language_test.dart index 4767c6a..c26b0a7 100644 --- a/test/language_test.dart +++ b/test/language_test.dart @@ -23,4 +23,27 @@ void main() { } }); }); + + group('isValid', () { + test('check if word exists in a list', () { + expect(Language.english.isValid('admit'), true); + }); + + test('check if word doesn\'t exist in a wrong list', () { + expect(Language.simplifiedChinese.isValid('admit'), false); + }); + + test('check if word doesn\'t exist in a list', () { + expect(Language.english.isValid('hey'), false); + }); + + // https://github.com/flutter/flutter/issues/104927#issuecomment-1141319254 + test('check if word is NFKD, no', () { + expect(Language.french.isValid('échelle'), false); // non NFKD + }); + + test('check if word is NFKD, yes', () { + expect(Language.french.isValid('échelle'), true); // NFKD + }); + }); }