Permalink
Browse files

feature: Changed to 'test', improved password-pattern

  • Loading branch information...
MikeMitterer committed Oct 22, 2015
1 parent 3345521 commit 13e09267655f9a059ed22fbc89ad525b22a9b98f
Showing with 30 additions and 32 deletions.
  1. +1 −0 Validate.iml
  2. +4 −1 lib/src/model/validate.dart
  3. +6 −4 pubspec.yaml
  4. +12 −5 test/src/validate_test.dart
  5. +7 −9 test/test.dart
  6. +0 −13 test/test.html
@@ -3,6 +3,7 @@
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.pub" />
<excludeFolder url="file://$MODULE_DIR$/build" />
<excludeFolder url="file://$MODULE_DIR$/packages" />
<excludeFolder url="file://$MODULE_DIR$/test/packages" />
@@ -31,10 +31,13 @@ class instanceCheck<T> {

/**
* Constructor. This class should not normally be instantiated.
* Pattern-RegExp:
* http://goo.gl/jxPnU3
* http://www.mkyong.com/regular-expressions/how-to-validate-password-with-regular-expression/
*/
abstract class Validate {
static const String PATTERN_EMAIL = "^([0-9a-zA-Z]([-.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})\$";
static const String PATTERN_PW = "((?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#\$%]).{8,15})"; // http://www.mkyong.com/regular-expressions/how-to-validate-password-with-regular-expression/
static const String PATTERN_PW = "^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[@#\$%])[0-9a-zA-Z@#\$%]{8,15}\$";
static const String PATTERN_ALPHANUMERIC = "^[a-zA-Z0-9öäüÖÄÜß]+\$";
static const String PATTERN_HEX = "^(0x[a-fA-F0-9]+)|([a-fA-F0-9])+\$";
static const String PATTERN_UUID = "^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}\$";
@@ -6,8 +6,10 @@ homepage: https://github.com/MikeMitterer/dart-validate

dependencies:

browser: ^0.10.0

logging: ^0.11.0
logging_handlers: ^0.8.0

dev_dependencies:
browser: any
unittest: any
logging: any
console_log_handler: any
test: any
@@ -85,17 +85,24 @@ testValidate() {
expect(() => (Validate.isEmail("urbi@orbi.it")),returnsNormally);
expect(() => (Validate.isEmail("urbi@orbit")),throwsA(new isInstanceOf<ArgumentError>()));

expect(() => (Validate.isPassword("1abcdefGH#")),returnsNormally);
expect(() => (Validate.isPassword("urbi@orbi.it")),throwsA(new isInstanceOf<ArgumentError>()));

expect(() => (Validate.isAlphaNumeric("123abcdö")),returnsNormally);
expect(() => (Validate.isAlphaNumeric("123a#bcd")),throwsA(new isInstanceOf<ArgumentError>()));

expect(() => (Validate.isHex("1234567890abcdef")),returnsNormally);
expect(() => (Validate.isHex("0x1234567890abcdef")),returnsNormally);
expect(() => (Validate.isHex("1234567890abcdefg")),throwsA(new isInstanceOf<ArgumentError>()));
});

});

test('> password', () {
expect(() => (Validate.isPassword("1abcdefGH#")),returnsNormally);

expect(() => (Validate.isPassword("urbi@orbi.it")),throwsA(new isInstanceOf<ArgumentError>()));
expect(() => (Validate.isPassword("1234567890abcdefGH#")),throwsA(new isInstanceOf<ArgumentError>()));
expect(() => (Validate.isPassword("12345678aA# ")),throwsA(new isInstanceOf<ArgumentError>()));
expect(() => (Validate.isPassword("12345678aA'")),throwsA(new isInstanceOf<ArgumentError>()));
expect(() => (Validate.isPassword("")),throwsA(new isInstanceOf<ArgumentError>()));
});

test('> inclusive', () {
expect(() => (Validate.inclusiveBetween(0,2,2)),returnsNormally);
expect(() => (Validate.inclusiveBetween(0,2,3)),throwsA(new isInstanceOf<ArgumentError>()));
@@ -1,25 +1,23 @@
// ----------------------------------------------------------------------------
// Start der Tests mit:
// pub run test test/test.dart
//
library test;

import 'package:unittest/unittest.dart';
//import 'package:unittest/html_enhanced_config.dart';
import 'package:test/test.dart';

//-----------------------------------------------------------------------------
// Logging

import 'package:logging/logging.dart';
import 'package:console_log_handler/console_log_handler.dart';
import 'package:logging_handlers/logging_handlers_shared.dart';

import 'package:validate/validate.dart';

part 'src/validate_test.dart';

//
// Mehr Infos: http://www.dartlang.org/articles/dart-unit-tests/
//
main() {
//useHtmlEnhancedConfiguration();
configLogging();

testValidate();
}

@@ -29,5 +27,5 @@ void configLogging() {
// now control the logging.
// Turn off all logging first
Logger.root.level = Level.INFO;
Logger.root.onRecord.listen(new LogConsoleHandler());
Logger.root.onRecord.listen(new LogPrintHandler());
}

This file was deleted.

Oops, something went wrong.

0 comments on commit 13e0926

Please sign in to comment.