From 6091e9c491ca77de5ccbc8efa04772b9fecb42ef Mon Sep 17 00:00:00 2001
From: eeichinger
Date: Sun, 26 Jul 2009 17:49:40 +0000
Subject: [PATCH] SPRNET-1234
---
BreakingChanges-1.3.txt | 4 +-
.../Spring.Core/Spring.Core.2008.csproj | 2 +
.../Validation/AnyValidatorGroup.cs | 14 +-
.../Validation/BaseSimpleValidator.cs | 123 ++++++++++++++++++
.../Spring.Core/Validation/BaseValidator.cs | 63 +--------
.../Validation/BaseValidatorGroup.cs | 111 ++++++++++++++++
.../Validation/CollectionValidator.cs | 41 ++++--
.../Validation/ExclusiveValidatorGroup.cs | 14 +-
.../Spring.Core/Validation/ValidatorGroup.cs | 98 +++-----------
.../Validators/ConditionValidator.cs | 2 +-
.../Validators/CreditCardValidator.cs | 2 +-
.../Validation/Validators/EmailValidator.cs | 2 +-
.../Validation/Validators/ISBNValidator.cs | 2 +-
.../Validators/RegularExpressionValidator.cs | 2 +-
.../Validators/RequiredValidator.cs | 2 +-
.../Validation/Validators/UrlValidator.cs | 24 ++--
.../Validation/HelperClasses.cs | 2 +-
.../Validation/ValidatorGroupTests.cs | 8 --
18 files changed, 329 insertions(+), 187 deletions(-)
create mode 100644 src/Spring/Spring.Core/Validation/BaseSimpleValidator.cs
create mode 100644 src/Spring/Spring.Core/Validation/BaseValidatorGroup.cs
diff --git a/BreakingChanges-1.3.txt b/BreakingChanges-1.3.txt
index 728c8b4d..af18d826 100644
--- a/BreakingChanges-1.3.txt
+++ b/BreakingChanges-1.3.txt
@@ -1,4 +1,4 @@
-Changes (1.2.0 to 1.2.1 or greater)
+Changes (1.2.0 to 1.3 or greater)
========================
Spring.Core
@@ -32,6 +32,8 @@ Spring.Core
4. AbstractApplicationContext.CaseSensitive renamed to AbstractApplicationContext.IsCaseSensitive
+5. Spring.Validation: Base class BaseValidator changed to BaseSingleValidator for single validators as compared to group validators
+ which now commonly derive from BaseGroupValidator instead of ValidatorGroup
Spring.Aop
----------
diff --git a/src/Spring/Spring.Core/Spring.Core.2008.csproj b/src/Spring/Spring.Core/Spring.Core.2008.csproj
index 519d34d6..f74c5215 100644
--- a/src/Spring/Spring.Core/Spring.Core.2008.csproj
+++ b/src/Spring/Spring.Core/Spring.Core.2008.csproj
@@ -1044,6 +1044,8 @@
Code
+
+
diff --git a/src/Spring/Spring.Core/Validation/AnyValidatorGroup.cs b/src/Spring/Spring.Core/Validation/AnyValidatorGroup.cs
index 267dc85e..24ad66fa 100644
--- a/src/Spring/Spring.Core/Validation/AnyValidatorGroup.cs
+++ b/src/Spring/Spring.Core/Validation/AnyValidatorGroup.cs
@@ -1,7 +1,7 @@
#region License
/*
- * Copyright 2002-2004 the original author or authors.
+ * Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,6 @@
#endregion
using System.Collections;
-
using Spring.Expressions;
namespace Spring.Validation
@@ -37,9 +36,11 @@ namespace Spring.Validation
/// for the contained validators, but only if this validator is not valid (meaning, when none
/// of the contained validators are valid).
///
+ /// Note, that defaults to true for this validator type!
///
/// Aleksandar Seovic
- public class AnyValidatorGroup : ValidatorGroup
+ /// Erich Eichinger
+ public class AnyValidatorGroup : BaseValidatorGroup
{
#region Constructors
@@ -55,7 +56,8 @@ namespace Spring.Validation
/// Initializes a new instance of the class.
///
/// The expression that determines if this validator should be evaluated.
- public AnyValidatorGroup(string when) : base(when)
+ public AnyValidatorGroup(string when)
+ : base(when)
{
this.FastValidate = true;
}
@@ -64,7 +66,8 @@ namespace Spring.Validation
/// Initializes a new instance of the class.
///
/// The expression that determines if this validator should be evaluated.
- public AnyValidatorGroup(IExpression when) : base(when)
+ public AnyValidatorGroup(IExpression when)
+ : base(when)
{
this.FastValidate = true;
}
@@ -80,6 +83,7 @@ namespace Spring.Validation
/// True if validation was successful, False otherwise.
protected override bool ValidateGroup(IDictionary contextParams, IValidationErrors errors, object validationContext)
{
+ // capture errors in separate collection to only add them to the error collector in case of errors
ValidationErrors tmpErrors = new ValidationErrors();
bool valid = false;
foreach (IValidator validator in Validators)
diff --git a/src/Spring/Spring.Core/Validation/BaseSimpleValidator.cs b/src/Spring/Spring.Core/Validation/BaseSimpleValidator.cs
new file mode 100644
index 00000000..d25e5540
--- /dev/null
+++ b/src/Spring/Spring.Core/Validation/BaseSimpleValidator.cs
@@ -0,0 +1,123 @@
+#region License
+
+/*
+ * Copyright © 2002-2009 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#endregion
+
+using System.Collections;
+using Spring.Expressions;
+
+namespace Spring.Validation
+{
+ ///
+ /// Base class that defines common properties for all single validators.
+ ///
+ ///
+ ///
+ /// Custom single validators should always extend this class instead of
+ /// simply implementing interface, in
+ /// order to inherit common validator functionality.
+ ///
+ ///
+ /// Aleksandar Seovic
+ /// Erich Eichinger
+ public abstract class BaseSimpleValidator : BaseValidator
+ {
+ private IExpression test;
+
+ ///
+ /// Gets or sets the test expression.
+ ///
+ /// The test expression.
+ public IExpression Test
+ {
+ get { return test; }
+ set { test = value; }
+ }
+
+ ///
+ /// Creates a new instance of the validator without any
+ /// and criteria
+ ///
+ public BaseSimpleValidator()
+ {
+ }
+
+ ///
+ /// Creates a new instance of the class.
+ ///
+ /// The expression to validate.
+ /// The expression that determines if this validator should be evaluated.
+ public BaseSimpleValidator(string test, string when)
+ : base( when)
+ {
+ this.test = (test != null ? Expression.Parse(test) : null);
+ }
+
+ ///
+ /// Creates a new instance of the class.
+ ///
+ /// The expression to validate.
+ /// The expression that determines if this validator should be evaluated.
+ public BaseSimpleValidator(IExpression test, IExpression when):base(when)
+ {
+ this.test = test;
+ }
+
+ ///
+ /// Validates the specified object.
+ ///
+ /// The object to validate.
+ /// Additional context parameters.
+ /// instance to add error messages to.
+ /// True if validation was successful, False otherwise.
+ public override bool Validate(object validationContext, IDictionary contextParams, IValidationErrors errors)
+ {
+ bool valid = true;
+
+ if (EvaluateWhen(validationContext, contextParams))
+ {
+ valid = Validate(EvaluateTest(validationContext, contextParams));
+ ProcessActions(valid, validationContext, contextParams, errors);
+ }
+
+ return valid;
+ }
+
+ ///
+ /// Validates test object.
+ ///
+ /// Object to validate.
+ /// True if specified object is valid, False otherwise.
+ protected abstract bool Validate(object objectToValidate);
+
+ ///
+ /// Evaluates test expression.
+ ///
+ /// Root context to use for expression evaluation.
+ /// Additional context parameters.
+ /// Result of the test expression evaluation, or validation context if test is null.
+ protected object EvaluateTest(object rootContext, IDictionary contextParams)
+ {
+ if (Test == null)
+ {
+ return rootContext;
+ }
+ return Test.GetValue(rootContext, contextParams);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Spring/Spring.Core/Validation/BaseValidator.cs b/src/Spring/Spring.Core/Validation/BaseValidator.cs
index 2820d339..6f4095ce 100644
--- a/src/Spring/Spring.Core/Validation/BaseValidator.cs
+++ b/src/Spring/Spring.Core/Validation/BaseValidator.cs
@@ -1,7 +1,7 @@
#region License
/*
- * Copyright © 2002-2005 the original author or authors.
+ * Copyright © 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,15 +18,10 @@
#endregion
-#region Imports
-
using System;
using System.Collections;
-
using Spring.Expressions;
-#endregion
-
namespace Spring.Validation
{
///
@@ -40,13 +35,13 @@ namespace Spring.Validation
///
///
/// Aleksandar Seovic
+ /// Erich Eichinger
public abstract class BaseValidator : IValidator
{
#region Fields
private IList actions = new ArrayList();
- private IExpression test;
private IExpression when;
#endregion
@@ -62,20 +57,17 @@ namespace Spring.Validation
///
/// Creates a new instance of the class.
///
- /// The expression to validate.
/// The expression that determines if this validator should be evaluated.
- public BaseValidator(string test, string when)
- : this((test != null ? Expression.Parse(test) : null), (when != null ? Expression.Parse(when) : null))
+ public BaseValidator(string when)
+ : this((when != null ? Expression.Parse(when) : null))
{}
///
/// Creates a new instance of the class.
///
- /// The expression to validate.
/// The expression that determines if this validator should be evaluated.
- public BaseValidator(IExpression test, IExpression when)
+ public BaseValidator(IExpression when)
{
- this.test = test;
this.when = when;
}
@@ -83,16 +75,6 @@ namespace Spring.Validation
#region Properties
- ///
- /// Gets or sets the test expression.
- ///
- /// The test expression.
- public IExpression Test
- {
- get { return test; }
- set { test = value; }
- }
-
///
/// Gets or sets the expression that determines if this validator should be evaluated.
///
@@ -133,43 +115,10 @@ namespace Spring.Validation
/// Additional context parameters.
/// instance to add error messages to.
/// True if validation was successful, False otherwise.
- public virtual bool Validate(object validationContext, IDictionary contextParams, IValidationErrors errors)
- {
- bool valid = true;
-
- if (EvaluateWhen(validationContext, contextParams))
- {
- valid = Validate(EvaluateTest(validationContext, contextParams));
- ProcessActions(valid, validationContext, contextParams, errors);
- }
-
- return valid;
- }
-
- ///
- /// Validates test object.
- ///
- /// Object to validate.
- /// True if specified object is valid, False otherwise.
- protected abstract bool Validate(object objectToValidate);
+ public abstract bool Validate(object validationContext, IDictionary contextParams, IValidationErrors errors);
#region Helper Methods
- ///
- /// Evaluates test expression.
- ///
- /// Root context to use for expression evaluation.
- /// Additional context parameters.
- /// Result of the test expression evaluation, or validation context if test is null.
- protected object EvaluateTest(object rootContext, IDictionary contextParams)
- {
- if (Test == null)
- {
- return rootContext;
- }
- return Test.GetValue(rootContext, contextParams);
- }
-
///
/// Evaluates when expression.
///
diff --git a/src/Spring/Spring.Core/Validation/BaseValidatorGroup.cs b/src/Spring/Spring.Core/Validation/BaseValidatorGroup.cs
new file mode 100644
index 00000000..804b9878
--- /dev/null
+++ b/src/Spring/Spring.Core/Validation/BaseValidatorGroup.cs
@@ -0,0 +1,111 @@
+#region License
+
+/*
+ * Copyright © 2002-2009 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#endregion
+
+using System.Collections;
+using Spring.Expressions;
+
+namespace Spring.Validation
+{
+ ///
+ /// Base class for composite validators
+ ///
+ public abstract class BaseValidatorGroup : BaseValidator
+ {
+ // TODO (EE): extend validation schema for "FastValidate"
+
+ private IList validators = new ArrayList();
+ private bool fastValidate = false;
+
+ ///
+ /// Initializes a new instance
+ ///
+ public BaseValidatorGroup()
+ {}
+
+ ///
+ /// Initializes a new instance
+ ///
+ /// The expression that determines if this validator should be evaluated.
+ public BaseValidatorGroup(string when)
+ : base(when)
+ {}
+
+ ///
+ /// Initializes a new instance
+ ///
+ /// The expression that determines if this validator should be evaluated.
+ public BaseValidatorGroup(IExpression when)
+ : base(when)
+ {}
+
+ ///
+ /// Gets or sets the child validators.
+ ///
+ /// The validators.
+ public IList Validators
+ {
+ get { return validators; }
+ set { validators = value; }
+ }
+
+ ///
+ /// When set true, shortcircuits evaluation.
+ ///
+ ///
+ /// Setting this property true causes the evaluation process to prematurely abort
+ /// if the end result is known. Any remaining child validators will not be considered then.
+ /// Setting this value false causes implementations to evaluate all child validators, regardless
+ /// of the potentially already known result.
+ ///
+ public bool FastValidate
+ {
+ get { return fastValidate; }
+ set { fastValidate = value; }
+ }
+
+ ///
+ /// Validates the specified object.
+ ///
+ /// The object to validate.
+ /// Additional context parameters.
+ /// instance to add error messages to.
+ /// True if validation was successful, False otherwise.
+ public override bool Validate(object validationContext, IDictionary contextParams, IValidationErrors errors)
+ {
+ if (EvaluateWhen(validationContext, contextParams))
+ {
+ bool valid = ValidateGroup(contextParams, errors, validationContext);
+ ProcessActions(valid, validationContext, contextParams, errors);
+ return valid;
+ }
+
+ return true;
+ }
+
+ ///
+ /// Actual implementation how to validate the specified object.
+ ///
+ /// The object to validate.
+ /// Additional context parameters.
+ /// instance to add error messages to.
+ /// True if validation was successful, False otherwise.
+ protected abstract bool ValidateGroup(IDictionary contextParams, IValidationErrors errors, object validationContext);
+ }
+}
\ No newline at end of file
diff --git a/src/Spring/Spring.Core/Validation/CollectionValidator.cs b/src/Spring/Spring.Core/Validation/CollectionValidator.cs
index fda98e79..a9d54b7b 100644
--- a/src/Spring/Spring.Core/Validation/CollectionValidator.cs
+++ b/src/Spring/Spring.Core/Validation/CollectionValidator.cs
@@ -1,3 +1,23 @@
+#region License
+
+/*
+ * Copyright 2002-2009 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#endregion
+
using System;
using System.Collections;
using Spring.Expressions;
@@ -13,9 +33,10 @@ namespace Spring.Validation
/// collection are valid for all of the objects in the specified collection.
///
///
- /// You can specify if you want to validate all of the collection elements regardless of the errors, by
- /// setting the ValidateAll property to true.
+ /// You can specify if you want to validate all of the collection elements regardless of the errors by
+ /// setting the property to false.
///
+ /// Note, that defaults to true for this validator type!
///
/// If you set the IncludeElementErrors property to true,
/// ValidationErrors collection will contain a union of all validation error messages
@@ -25,7 +46,7 @@ namespace Spring.Validation
///
/// Damjan Tomic
/// Aleksandar Seovic
- public class CollectionValidator : ValidatorGroup
+ public class CollectionValidator : BaseValidatorGroup
{
#region Fields
@@ -40,7 +61,7 @@ namespace Spring.Validation
/// Gets or sets the value that indicates whether to validate all elements of the collection
/// regardless of the errors.
///
- /// This is just an alias for
+ /// This is just an alias for property
public bool ValidateAll
{
get { return !base.FastValidate; }
@@ -102,12 +123,10 @@ namespace Spring.Validation
///
/// The bool that determines whether Validate method should collect
/// all error messages returned by the item validators
-
- public CollectionValidator(IExpression when, bool validateAll, bool includeElementErrors)
- : base(when)
+ public CollectionValidator(string when, bool validateAll, bool includeElementErrors)
+ : this((when != null ? Expression.Parse(when) : null), validateAll,includeElementErrors)
{
this.FastValidate = validateAll;
- this.includeElementErrors = includeElementErrors;
}
///
@@ -119,10 +138,12 @@ namespace Spring.Validation
///
/// The bool that determines whether Validate method should collect
/// all error messages returned by the item validators
- public CollectionValidator(string when, bool validateAll, bool includeElementErrors)
- : this((when != null ? Expression.Parse(when) : null), validateAll,includeElementErrors)
+
+ public CollectionValidator(IExpression when, bool validateAll, bool includeElementErrors)
+ : base(when)
{
this.FastValidate = validateAll;
+ this.includeElementErrors = includeElementErrors;
}
#endregion
diff --git a/src/Spring/Spring.Core/Validation/ExclusiveValidatorGroup.cs b/src/Spring/Spring.Core/Validation/ExclusiveValidatorGroup.cs
index 1711c3b0..91f17a50 100644
--- a/src/Spring/Spring.Core/Validation/ExclusiveValidatorGroup.cs
+++ b/src/Spring/Spring.Core/Validation/ExclusiveValidatorGroup.cs
@@ -1,7 +1,7 @@
#region License
/*
- * Copyright 2002-2004 the original author or authors.
+ * Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,6 @@
#endregion
using System.Collections;
-
using Spring.Expressions;
namespace Spring.Validation
@@ -37,11 +36,12 @@ namespace Spring.Validation
/// of the contained validators are valid).
///
///
- /// By default, this validator group uses == true semantics.
+ /// By default, this validator group uses == true semantics.
///
///
/// Aleksandar Seovic
- public class ExclusiveValidatorGroup : ValidatorGroup
+ /// Erich Eichinger
+ public class ExclusiveValidatorGroup : BaseValidatorGroup
{
#region Constructors
@@ -57,7 +57,8 @@ namespace Spring.Validation
/// Initializes a new instance of the class.
///
/// The expression that determines if this validator should be evaluated.
- public ExclusiveValidatorGroup(string when) : base(when)
+ public ExclusiveValidatorGroup(string when)
+ : base(when)
{
this.FastValidate = true;
}
@@ -66,7 +67,8 @@ namespace Spring.Validation
/// Initializes a new instance of the class.
///
/// The expression that determines if this validator should be evaluated.
- public ExclusiveValidatorGroup(IExpression when) : base(when)
+ public ExclusiveValidatorGroup(IExpression when)
+ : base(when)
{
this.FastValidate = true;
}
diff --git a/src/Spring/Spring.Core/Validation/ValidatorGroup.cs b/src/Spring/Spring.Core/Validation/ValidatorGroup.cs
index 84954954..466c81bb 100644
--- a/src/Spring/Spring.Core/Validation/ValidatorGroup.cs
+++ b/src/Spring/Spring.Core/Validation/ValidatorGroup.cs
@@ -1,7 +1,7 @@
#region License
/*
- * Copyright 2002-2004 the original author or authors.
+ * Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,9 +18,7 @@
#endregion
-using System;
using System.Collections;
-
using Spring.Expressions;
namespace Spring.Validation
@@ -39,84 +37,36 @@ namespace Spring.Validation
///
///
/// Aleksandar Seovic
- public class ValidatorGroup : BaseValidator
+ /// Erich Eichinger
+ public class ValidatorGroup : BaseValidatorGroup
{
- #region Fields
-
- private IList validators = new ArrayList();
- private bool fastValidate = false;
- #endregion
-
#region Constructors
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance
///
- public ValidatorGroup()
- {}
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The expression that determines if this validator should be evaluated.
- public ValidatorGroup(string when) : this((when != null ? Expression.Parse(when) : null))
- {}
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The expression that determines if this validator should be evaluated.
- public ValidatorGroup(IExpression when) : base(null, when)
- {}
-
- #endregion
-
- #region Properties
-
- ///
- /// Gets or sets the validators.
- ///
- /// The validators.
- public IList Validators
+ public ValidatorGroup() : base()
{
- get { return validators; }
- set { validators = value; }
}
///
- /// When set true, shortcircuits evaluation.
+ /// Initializes a new instance
///
- ///
- /// The validators within the group will only be validated
- /// in order until the first validator fails.
- ///
- public bool FastValidate
+ /// The expression that determines if this validator should be evaluated.
+ public ValidatorGroup(string when) : base(when)
+ {
+ }
+
+ ///
+ /// Initializes a new instance
+ ///
+ /// The expression that determines if this validator should be evaluated.
+ public ValidatorGroup(IExpression when) : base(when)
{
- get { return fastValidate; }
- set { fastValidate = value; }
}
#endregion
- ///
- /// Validates the specified object.
- ///
- /// The object to validate.
- /// Additional context parameters.
- /// instance to add error messages to.
- /// True if validation was successful, False otherwise.
- public override bool Validate(object validationContext, IDictionary contextParams, IValidationErrors errors)
- {
- if (EvaluateWhen(validationContext, contextParams))
- {
- bool valid = ValidateGroup(contextParams, errors, validationContext);
- ProcessActions(valid, validationContext, contextParams, errors);
- return valid;
- }
-
- return true;
- }
-
///
/// Actual implementation how to validate the specified object.
///
@@ -124,28 +74,18 @@ namespace Spring.Validation
/// Additional context parameters.
/// instance to add error messages to.
/// True if validation was successful, False otherwise.
- protected virtual bool ValidateGroup(IDictionary contextParams, IValidationErrors errors, object validationContext)
+ protected override bool ValidateGroup(IDictionary contextParams, IValidationErrors errors, object validationContext)
{
bool valid = true;
- foreach (IValidator validator in validators)
+ foreach (IValidator validator in this.Validators)
{
valid = validator.Validate(validationContext, contextParams, errors) && valid;
- if (!valid && FastValidate)
+ if (!valid && this.FastValidate)
{
break;
}
}
return valid;
}
-
- ///
- /// Doesn't do anything for validator group as there is no single test.
- ///
- /// Object to validate.
- /// True if specified object is valid, False otherwise.
- protected override bool Validate(object objectToValidate)
- {
- throw new NotSupportedException("Validator group does not support this method.");
- }
}
}
\ No newline at end of file
diff --git a/src/Spring/Spring.Core/Validation/Validators/ConditionValidator.cs b/src/Spring/Spring.Core/Validation/Validators/ConditionValidator.cs
index e62daa5a..d7e97a02 100644
--- a/src/Spring/Spring.Core/Validation/Validators/ConditionValidator.cs
+++ b/src/Spring/Spring.Core/Validation/Validators/ConditionValidator.cs
@@ -33,7 +33,7 @@ namespace Spring.Validation
/// Evaluates validator test using condition evaluator.
///
/// Aleksandar Seovic
- public class ConditionValidator : BaseValidator
+ public class ConditionValidator : BaseSimpleValidator
{
#region Constructors
diff --git a/src/Spring/Spring.Core/Validation/Validators/CreditCardValidator.cs b/src/Spring/Spring.Core/Validation/Validators/CreditCardValidator.cs
index 6106774a..a061c01f 100644
--- a/src/Spring/Spring.Core/Validation/Validators/CreditCardValidator.cs
+++ b/src/Spring/Spring.Core/Validation/Validators/CreditCardValidator.cs
@@ -37,7 +37,7 @@ namespace Spring.Validation.Validators
/// the value of property to a concrete
/// instance.
///
- public class CreditCardValidator : BaseValidator
+ public class CreditCardValidator : BaseSimpleValidator
{
#region Properties
diff --git a/src/Spring/Spring.Core/Validation/Validators/EmailValidator.cs b/src/Spring/Spring.Core/Validation/Validators/EmailValidator.cs
index c1de00de..cc280a60 100644
--- a/src/Spring/Spring.Core/Validation/Validators/EmailValidator.cs
+++ b/src/Spring/Spring.Core/Validation/Validators/EmailValidator.cs
@@ -39,7 +39,7 @@ namespace Spring.Validation.Validators
/// pass validator, even though there is no TLD "nowhere".
///
/// Goran Milosavljevic
- public class EmailValidator : BaseValidator
+ public class EmailValidator : BaseSimpleValidator
{
#region Constructors
diff --git a/src/Spring/Spring.Core/Validation/Validators/ISBNValidator.cs b/src/Spring/Spring.Core/Validation/Validators/ISBNValidator.cs
index cff00112..ee765018 100644
--- a/src/Spring/Spring.Core/Validation/Validators/ISBNValidator.cs
+++ b/src/Spring/Spring.Core/Validation/Validators/ISBNValidator.cs
@@ -33,7 +33,7 @@ namespace Spring.Validation.Validators
/// Validates that the object is valid ISBN-10 or ISBN-13 value.
///
/// Goran Milosavljevic
- public class ISBNValidator : BaseValidator
+ public class ISBNValidator : BaseSimpleValidator
{
#region Constructors
diff --git a/src/Spring/Spring.Core/Validation/Validators/RegularExpressionValidator.cs b/src/Spring/Spring.Core/Validation/Validators/RegularExpressionValidator.cs
index 6d45288e..edd9192f 100644
--- a/src/Spring/Spring.Core/Validation/Validators/RegularExpressionValidator.cs
+++ b/src/Spring/Spring.Core/Validation/Validators/RegularExpressionValidator.cs
@@ -40,7 +40,7 @@ namespace Spring.Validation
///
///
/// Aleksandar Seovic
- public class RegularExpressionValidator : BaseValidator
+ public class RegularExpressionValidator : BaseSimpleValidator
{
#region Fields
diff --git a/src/Spring/Spring.Core/Validation/Validators/RequiredValidator.cs b/src/Spring/Spring.Core/Validation/Validators/RequiredValidator.cs
index d5b046a6..9f23111f 100644
--- a/src/Spring/Spring.Core/Validation/Validators/RequiredValidator.cs
+++ b/src/Spring/Spring.Core/Validation/Validators/RequiredValidator.cs
@@ -68,7 +68,7 @@ namespace Spring.Validation
///
///
/// Aleksandar Seovic
- public class RequiredValidator : BaseValidator
+ public class RequiredValidator : BaseSimpleValidator
{
#region Constructors
diff --git a/src/Spring/Spring.Core/Validation/Validators/UrlValidator.cs b/src/Spring/Spring.Core/Validation/Validators/UrlValidator.cs
index 5d8cb670..d40130b6 100644
--- a/src/Spring/Spring.Core/Validation/Validators/UrlValidator.cs
+++ b/src/Spring/Spring.Core/Validation/Validators/UrlValidator.cs
@@ -1,7 +1,7 @@
#region License
/*
- * Copyright 2002-2005 the original author or authors.
+ * Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,31 +18,27 @@
#endregion
-#region Imports
-
-using System;
using System.Text.RegularExpressions;
using Spring.Expressions;
using Spring.Util;
-#endregion
-
namespace Spring.Validation.Validators
{
///
/// Validates that the value is valid URL.
///
/// Goran Milosavljevic
- public class UrlValidator : BaseValidator
+ public class UrlValidator : BaseSimpleValidator
{
- #region Constructors
-
- ///
- /// Creates a new instance of the UrlValidator class.
- ///
+ #region Constructors
+
+ ///
+ /// Creates a new instance of the UrlValidator class.
+ ///
public UrlValidator()
- {}
-
+ {
+ }
+
///
/// Creates a new instance of the UrlValidator class.
///
diff --git a/test/Spring/Spring.Core.Tests/Validation/HelperClasses.cs b/test/Spring/Spring.Core.Tests/Validation/HelperClasses.cs
index ba7a62a5..7423d4a4 100644
--- a/test/Spring/Spring.Core.Tests/Validation/HelperClasses.cs
+++ b/test/Spring/Spring.Core.Tests/Validation/HelperClasses.cs
@@ -27,7 +27,7 @@ using Spring.Validation.Actions;
namespace Spring.Validation
{
- public abstract class BaseTestValidator : BaseValidator
+ public abstract class BaseTestValidator : BaseSimpleValidator
{
private bool _wasCalled;
diff --git a/test/Spring/Spring.Core.Tests/Validation/ValidatorGroupTests.cs b/test/Spring/Spring.Core.Tests/Validation/ValidatorGroupTests.cs
index 0f21b28d..dab96005 100644
--- a/test/Spring/Spring.Core.Tests/Validation/ValidatorGroupTests.cs
+++ b/test/Spring/Spring.Core.Tests/Validation/ValidatorGroupTests.cs
@@ -129,13 +129,5 @@ namespace Spring.Validation
Assert.AreEqual(0, errors.GetErrors("errors").Count);
Assert.AreEqual(1, errors.GetErrors("existingErrors").Count);
}
-
- [Test]
- [ExpectedException(typeof(NotSupportedException))]
- public void TestNonSupportedValidateMethod()
- {
- this.Validate("xyz");
- }
-
}
}
\ No newline at end of file