diff --git a/example/lib/main.dart b/example/lib/main.dart index 70e3cf7..239b96d 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -43,7 +43,7 @@ class MalidadoresMain extends StatelessWidget { ), ElevatedButton( onPressed: () { - if (_formKey.currentState!.validate()) { + if (_formKey.currentState.validate()) { print('Valido'); } }, diff --git a/example/pubspec.lock b/example/pubspec.lock index 65ec816..2d54ab1 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -1,62 +1,48 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: - archive: - dependency: transitive - description: - name: archive - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.11" - args: - dependency: transitive - description: - name: args - url: "https://pub.dartlang.org" - source: hosted - version: "1.5.2" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.0" + version: "2.6.1" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" - charcode: + version: "2.1.0" + characters: dependency: transitive description: - name: charcode + name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" - collection: + version: "1.1.0" + charcode: dependency: transitive description: - name: collection + name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.14.11" - convert: + version: "1.2.0" + clock: dependency: transitive description: - name: convert + name: clock url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" - crypto: + version: "1.1.0" + collection: dependency: transitive description: - name: crypto + name: collection url: "https://pub.dartlang.org" source: hosted - version: "2.1.3" + version: "1.15.0" cupertino_icons: dependency: "direct main" description: @@ -64,6 +50,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.3" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -74,55 +67,27 @@ packages: description: flutter source: sdk version: "0.0.0" - image: - dependency: transitive - description: - name: image - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.4" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.6" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.8" + version: "1.3.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.6.4" - pedantic: - dependency: transitive - description: - name: pedantic - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.0+1" - petitparser: - dependency: transitive - description: - name: petitparser - url: "https://pub.dartlang.org" - source: hosted - version: "2.4.0" - quiver: - dependency: transitive - description: - name: quiver - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.5" + version: "1.8.0" sky_engine: dependency: transitive description: flutter @@ -134,69 +99,63 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.5.5" + version: "1.8.1" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.11" + version: "0.3.0" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.3.0" validadores: dependency: "direct dev" description: path: ".." relative: true source: path - version: "0.0.2" + version: "1.0.3" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" - xml: - dependency: transitive - description: - name: xml - url: "https://pub.dartlang.org" - source: hosted - version: "3.5.0" + version: "2.1.0" sdks: - dart: ">=2.4.0 <3.0.0" + dart: ">=2.12.0 <3.0.0" + flutter: ">=1.12.0" diff --git a/pubspec.lock b/pubspec.lock index ad6d1df..f5c3079 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,6 +1,27 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + url: "https://pub.dartlang.org" + source: hosted + version: "22.0.0" + analyzer: + dependency: transitive + description: + name: analyzer + url: "https://pub.dartlang.org" + source: hosted + version: "1.7.1" + args: + dependency: transitive + description: + name: args + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.0" async: dependency: transitive description: @@ -29,6 +50,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0" + cli_util: + dependency: transitive + description: + name: cli_util + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.3" clock: dependency: transitive description: @@ -43,6 +71,27 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.15.0" + convert: + dependency: transitive + description: + name: convert + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.1" + coverage: + dependency: transitive + description: + name: coverage + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" + crypto: + dependency: transitive + description: + name: crypto + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.1" fake_async: dependency: transitive description: @@ -50,6 +99,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0" + file: + dependency: transitive + description: + name: file + url: "https://pub.dartlang.org" + source: hosted + version: "6.1.2" flutter: dependency: "direct main" description: flutter @@ -60,6 +116,48 @@ packages: description: flutter source: sdk version: "0.0.0" + glob: + dependency: transitive + description: + name: glob + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.1" + http_parser: + dependency: transitive + description: + name: http_parser + url: "https://pub.dartlang.org" + source: hosted + version: "4.0.0" + io: + dependency: transitive + description: + name: io + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" + js: + dependency: transitive + description: + name: js + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.3" + logging: + dependency: transitive + description: + name: logging + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" matcher: dependency: transitive description: @@ -74,6 +172,27 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.3.0" + mime: + dependency: transitive + description: + name: mime + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" + node_preamble: + dependency: transitive + description: + name: node_preamble + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + package_config: + dependency: transitive + description: + name: package_config + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" path: dependency: transitive description: @@ -81,11 +200,74 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0" + pedantic: + dependency: transitive + description: + name: pedantic + url: "https://pub.dartlang.org" + source: hosted + version: "1.11.1" + pool: + dependency: transitive + description: + name: pool + url: "https://pub.dartlang.org" + source: hosted + version: "1.5.0" + pub_semver: + dependency: transitive + description: + name: pub_semver + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + shelf: + dependency: transitive + description: + name: shelf + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + shelf_packages_handler: + dependency: transitive + description: + name: shelf_packages_handler + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.0" + shelf_static: + dependency: transitive + description: + name: shelf_static + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" sky_engine: dependency: transitive description: flutter source: sdk version: "0.0.99" + source_map_stack_trace: + dependency: transitive + description: + name: source_map_stack_trace + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + source_maps: + dependency: transitive + description: + name: source_maps + url: "https://pub.dartlang.org" + source: hosted + version: "0.10.10" source_span: dependency: transitive description: @@ -121,6 +303,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0" + test: + dependency: "direct dev" + description: + name: test + url: "https://pub.dartlang.org" + source: hosted + version: "1.16.8" test_api: dependency: transitive description: @@ -128,6 +317,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.3.0" + test_core: + dependency: transitive + description: + name: test_core + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.19" typed_data: dependency: transitive description: @@ -142,5 +338,41 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.0" + vm_service: + dependency: transitive + description: + name: vm_service + url: "https://pub.dartlang.org" + source: hosted + version: "6.2.0" + watcher: + dependency: transitive + description: + name: watcher + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + webkit_inspection_protocol: + dependency: transitive + description: + name: webkit_inspection_protocol + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" + yaml: + dependency: transitive + description: + name: yaml + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.0" sdks: dart: ">=2.12.0 <3.0.0" + flutter: ">=1.12.0" diff --git a/pubspec.yaml b/pubspec.yaml index bb9494b..c9f7e21 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -6,6 +6,7 @@ homepage: https://github.com/mtobbias/365apps-pack-validador environment: sdk: '>=2.12.0 <3.0.0' + flutter: ">=1.12.0" dependencies: flutter: @@ -14,6 +15,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter + test: ^1.16.8 flutter: plugin: diff --git a/test/ValidarCNPJ_test.dart b/test/ValidarCNPJ_test.dart index 3a94e94..56fd9fc 100644 --- a/test/ValidarCNPJ_test.dart +++ b/test/ValidarCNPJ_test.dart @@ -2,50 +2,50 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:validadores/Validador.dart'; class _Contants { - static final TEST_NAME = "CNPJ"; - static final DEFAULT_MESSAGE_INVALID = "Campo Inválido"; - static final VALID_VALUE = "77287898000155"; - static final INVALID_VALUE = "77287898000154"; - static final INVALID_VALUE_00 = "00000000000"; - static final INVALID_VALUE_INC = "77287898000"; - static final INVALID_VALUE_NULL = null; + static final testName = "CNPJ"; + static final defaultMessageInvalid = "Campo Inválido"; + static final validValue = "77287898000155"; + static final invalidValue = "77287898000154"; + static final invalidValue00 = "00000000000"; + static final invalidValueInc = "77287898000"; + static final invalidValueNull = null; } void main() { - test(_Contants.TEST_NAME + ' INVALID_VALUE_INC', () { + test(_Contants.testName + ' invalidValueInc', () { var validador = Validador().add( - Validar.CPF, msg: _Contants.DEFAULT_MESSAGE_INVALID); - expect(_getDefaultResp(), validador.valido(_Contants.INVALID_VALUE_NULL)); + Validar.CPF, msg: _Contants.defaultMessageInvalid); + expect(_getDefaultResp(), validador.valido(_Contants.invalidValueNull)); }); - test(_Contants.TEST_NAME + ' INVALID_VALUE_INC', () { + test(_Contants.testName + ' invalidValueInc', () { var validador = Validador().add( - Validar.CNPJ, msg: _Contants.DEFAULT_MESSAGE_INVALID); - expect(_getDefaultResp(), validador.valido(_Contants.INVALID_VALUE_INC)); + Validar.CNPJ, msg: _Contants.defaultMessageInvalid); + expect(_getDefaultResp(), validador.valido(_Contants.invalidValueInc)); }); - test(_Contants.TEST_NAME + ' INVALID_VALUE_00', () { + test(_Contants.testName + ' invalidValue00', () { var validador = Validador().add( - Validar.CNPJ, msg: _Contants.DEFAULT_MESSAGE_INVALID); - expect(_getDefaultResp(), validador.valido(_Contants.INVALID_VALUE_00)); + Validar.CNPJ, msg: _Contants.defaultMessageInvalid); + expect(_getDefaultResp(), validador.valido(_Contants.invalidValue00)); }); - test(_Contants.TEST_NAME + ' VALIDO', () { + test(_Contants.testName + ' VALIDO', () { var validador = Validador().add( - Validar.CNPJ, msg: _Contants.DEFAULT_MESSAGE_INVALID); - expect(null, validador.valido(_Contants.VALID_VALUE)); + Validar.CNPJ, msg: _Contants.defaultMessageInvalid); + expect(null, validador.valido(_Contants.validValue)); }); - test(_Contants.TEST_NAME + ' INVALIDO', () { + test(_Contants.testName + ' INVALIDO', () { var validador = Validador().add( - Validar.CNPJ, msg: _Contants.DEFAULT_MESSAGE_INVALID); - expect(_getDefaultResp(), validador.valido(_Contants.INVALID_VALUE)); + Validar.CNPJ, msg: _Contants.defaultMessageInvalid); + expect(_getDefaultResp(), validador.valido(_Contants.invalidValue)); }); } _getDefaultResp() { - return List.from({_Contants.DEFAULT_MESSAGE_INVALID}).toString().toString(); + return List.from({_Contants.defaultMessageInvalid}).toString().toString(); } diff --git a/test/ValidarCPF_test.dart b/test/ValidarCPF_test.dart index ca86f8d..ee1c1e9 100644 --- a/test/ValidarCPF_test.dart +++ b/test/ValidarCPF_test.dart @@ -2,50 +2,50 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:validadores/Validador.dart'; class _Contants { - static final TEST_NAME = "CPF"; - static final DEFAULT_MESSAGE_INVALID = "Campo Inválido"; - static final VALID_VALUE = "99988877714"; - static final INVALID_VALUE = "99988877713"; - static final INVALID_VALUE_00 = "00000000000"; - static final INVALID_VALUE_INC = "999888777"; - static final INVALID_VALUE_NULL = null; + static final testeName = "CPF"; + static final defaultMessageInvalid = "Campo Inválido"; + static final validValue = "99988877714"; + static final invalidValue = "99988877713"; + static final invalidValue00 = "00000000000"; + static final invalidValueInc = "999888777"; + static final invalidValueNull = null; } void main() { - test(_Contants.TEST_NAME + ' INVALID_VALUE_INC', () { + test(_Contants.testeName + ' invalidValueInc', () { var validador = Validador().add( - Validar.CPF, msg: _Contants.DEFAULT_MESSAGE_INVALID); - expect(_getDefaultResp(), validador.valido(_Contants.INVALID_VALUE_NULL)); + Validar.CPF, msg: _Contants.defaultMessageInvalid); + expect(_getDefaultResp(), validador.valido(_Contants.invalidValueNull)); }); - test(_Contants.TEST_NAME + ' INVALID_VALUE_INC', () { + test(_Contants.testeName + ' invalidValueInc', () { var validador = Validador().add( - Validar.CPF, msg: _Contants.DEFAULT_MESSAGE_INVALID); - expect(_getDefaultResp(), validador.valido(_Contants.INVALID_VALUE_INC)); + Validar.CPF, msg: _Contants.defaultMessageInvalid); + expect(_getDefaultResp(), validador.valido(_Contants.invalidValueInc)); }); - test(_Contants.TEST_NAME + ' INVALID_VALUE_00', () { + test(_Contants.testeName + ' invalidValue00', () { var validador = Validador().add( - Validar.CPF, msg: _Contants.DEFAULT_MESSAGE_INVALID); - expect(_getDefaultResp(), validador.valido(_Contants.INVALID_VALUE_00)); + Validar.CPF, msg: _Contants.defaultMessageInvalid); + expect(_getDefaultResp(), validador.valido(_Contants.invalidValue00)); }); - test(_Contants.TEST_NAME + ' VALIDO', () { + test(_Contants.testeName + ' VALIDO', () { var validador = Validador().add( - Validar.CPF, msg: _Contants.DEFAULT_MESSAGE_INVALID); - expect(null, validador.valido(_Contants.VALID_VALUE)); + Validar.CPF, msg: _Contants.defaultMessageInvalid); + expect(null, validador.valido(_Contants.validValue)); }); - test(_Contants.TEST_NAME + ' INVALIDO', () { + test(_Contants.testeName + ' INVALIDO', () { var validador = Validador().add( - Validar.CPF, msg: _Contants.DEFAULT_MESSAGE_INVALID); - expect(_getDefaultResp(), validador.valido(_Contants.INVALID_VALUE)); + Validar.CPF, msg: _Contants.defaultMessageInvalid); + expect(_getDefaultResp(), validador.valido(_Contants.invalidValue)); }); } _getDefaultResp() { - return List.from({_Contants.DEFAULT_MESSAGE_INVALID}).toString().toString(); + return List.from({_Contants.defaultMessageInvalid}).toString().toString(); } diff --git a/test/ValidarEmail_test.dart b/test/ValidarEmail_test.dart index faddb1d..fd396ad 100644 --- a/test/ValidarEmail_test.dart +++ b/test/ValidarEmail_test.dart @@ -3,13 +3,13 @@ import 'package:validadores/Validador.dart'; class _Constants { - static final TEST_NAME ="EMAIL"; - static final DEFAULT_MESSAGE_INVALID ="Campo Inválido"; - static final VALID_VALUE = "marcelo.tobbias@gmail.com"; - static final VALID_VALUE_BR = "contato@registro.br"; - static final VALID_VALUE_COM_BR = "contato@365apps.com.br"; - static final INVALID_VALUE = "marcelo.tobbias@gmail"; - static final INVALID_VALUE_NULL = null; + static final testName ="EMAIL"; + static final defaultMessageInvalid ="Campo Inválido"; + static final validValue = "marcelo.tobbias@gmail.com"; + static final validValueBr = "contato@registro.br"; + static final validValueComBr = "contato@365apps.com.br"; + static final invalidValue = "marcelo.tobbias@gmail"; + static final invalidValueNull = null; } @@ -18,30 +18,30 @@ void main(){ /** * @see https://github.com/mtobbias/365apps-pack-validador/issues/1 */ - test(_Constants.TEST_NAME +' VALIDO_COM_BR', () { - var validador = Validador().add(Validar.EMAIL, msg: _Constants.DEFAULT_MESSAGE_INVALID); - expect(null,validador.valido(_Constants.VALID_VALUE_COM_BR)); + test(_Constants.testName +' VALIDO_COM_BR', () { + var validador = Validador().add(Validar.EMAIL, msg: _Constants.defaultMessageInvalid); + expect(null,validador.valido(_Constants.validValueComBr)); }); - test(_Constants.TEST_NAME +' VALIDO_BR', () { - var validador = Validador().add(Validar.EMAIL, msg: _Constants.DEFAULT_MESSAGE_INVALID); - expect(null,validador.valido(_Constants.VALID_VALUE_BR)); + test(_Constants.testName +' VALIDO_BR', () { + var validador = Validador().add(Validar.EMAIL, msg: _Constants.defaultMessageInvalid); + expect(null,validador.valido(_Constants.validValueBr)); }); - test(_Constants.TEST_NAME +' VALIDO', () { - var validador = Validador().add(Validar.EMAIL, msg: _Constants.DEFAULT_MESSAGE_INVALID); - expect(null,validador.valido(_Constants.VALID_VALUE)); + test(_Constants.testName +' VALIDO', () { + var validador = Validador().add(Validar.EMAIL, msg: _Constants.defaultMessageInvalid); + expect(null,validador.valido(_Constants.validValue)); }); - test(_Constants.TEST_NAME +' INVALIDO', () { - var validador = Validador().add(Validar.EMAIL, msg: _Constants.DEFAULT_MESSAGE_INVALID); - expect(List.from({_Constants.DEFAULT_MESSAGE_INVALID}).toString(),validador.valido(_Constants.INVALID_VALUE)); + test(_Constants.testName +' INVALIDO', () { + var validador = Validador().add(Validar.EMAIL, msg: _Constants.defaultMessageInvalid); + expect(List.from({_Constants.defaultMessageInvalid}).toString(),validador.valido(_Constants.invalidValue)); }); - test(_Constants.TEST_NAME +' INVALIDO', () { - var validador = Validador().add(Validar.EMAIL, msg: _Constants.DEFAULT_MESSAGE_INVALID); - expect(List.from({_Constants.DEFAULT_MESSAGE_INVALID}).toString(),validador.valido(_Constants.INVALID_VALUE_NULL)); + test(_Constants.testName +' INVALIDO', () { + var validador = Validador().add(Validar.EMAIL, msg: _Constants.defaultMessageInvalid); + expect(List.from({_Constants.defaultMessageInvalid}).toString(),validador.valido(_Constants.invalidValueNull)); }); }