User: roelofb
Date: 2008/08/28 02:35 AM
Removed:
/trunk/Components/Validator/Castle.Components.Validator.Tests/ValidatorTests/
NullableDateTimeValidatorTestCase.cs, NullableDateValidatorTestCase.cs,
NullableDecimalValidatorTestCase.cs, NullableDoubleValidatorTestCase.cs,
NullableIntegerValidatorTestCase.cs, NullableSingleValidatorTestCase.cs
/trunk/Components/Validator/Castle.Components.Validator/Validators/
NullableDateTimeValidator.cs, NullableDateValidator.cs,
NullableDecimalValidator.cs, NullableDoubleValidator.cs,
NullableIntegerValidator.cs, NullableSingleValidator.cs
Modified:
/trunk/Components/Validator/Castle.Components.Validator.Tests/
Castle.Components.Validator.Tests-vs2005.csproj,
Castle.Components.Validator.Tests-vs2008.csproj
/trunk/Components/Validator/Castle.Components.Validator/
Castle.Components.Validator-vs2005.csproj,
Castle.Components.Validator-vs2008.csproj, ValidatorRunner.cs
Log:
Removed the NullableType validators as they are identical to their
non-NullableType cousins.
File Changes:
Directory: /trunk/Components/Validator/Castle.Components.Validator/
===================================================================
File [modified]: Castle.Components.Validator-vs2005.csproj
Delta lines: +0 -6
===================================================================
---
trunk/Components/Validator/Castle.Components.Validator/Castle.Components.Validator-vs2008.csproj
2008-08-28 08:49:52 UTC (rev 5296)
+++
trunk/Components/Validator/Castle.Components.Validator/Castle.Components.Validator-vs2008.csproj
2008-08-28 09:35:29 UTC (rev 5297)
@@ -158,12 +158,6 @@
<Compile Include="Attributes\ValidateNonEmptyAttribute.cs" />
<Compile Include="IValidator.cs" />
<Compile Include="Validators\NotSameValueValidator.cs" />
- <Compile Include="Validators\NullableDateTimeValidator.cs" />
- <Compile Include="Validators\NullableDateValidator.cs" />
- <Compile Include="Validators\NullableDecimalValidator.cs" />
- <Compile Include="Validators\NullableDoubleValidator.cs" />
- <Compile Include="Validators\NullableIntegerValidator.cs" />
- <Compile Include="Validators\NullableSingleValidator.cs" />
<Compile Include="Validators\RangeValidator.cs" />
<Compile Include="Validators\RegularExpressionValidator.cs" />
File [modified]: Castle.Components.Validator-vs2008.csproj
Delta lines: +7 -7
===================================================================
--- trunk/Components/Validator/Castle.Components.Validator/ValidatorRunner.cs
2008-08-28 08:49:52 UTC (rev 5296)
+++ trunk/Components/Validator/Castle.Components.Validator/ValidatorRunner.cs
2008-08-28 09:35:29 UTC (rev 5297)
@@ -58,19 +58,19 @@
{
type2Validator = new Dictionary<Type, Type>();
type2Validator[typeof(Int16)] =
typeof(IntegerValidator);
- type2Validator[typeof(Nullable<Int16>)] =
typeof(NullableIntegerValidator);
+ type2Validator[typeof(Nullable<Int16>)] =
typeof(IntegerValidator);
type2Validator[typeof(Int32)] =
typeof(IntegerValidator);
- type2Validator[typeof(Nullable<Int32>)] =
typeof(NullableIntegerValidator);
+ type2Validator[typeof(Nullable<Int32>)] =
typeof(IntegerValidator);
type2Validator[typeof(Int64)] =
typeof(IntegerValidator);
- type2Validator[typeof(Nullable<Int64>)] =
typeof(NullableIntegerValidator);
+ type2Validator[typeof(Nullable<Int64>)] =
typeof(IntegerValidator);
type2Validator[typeof(Decimal)] =
typeof(DecimalValidator);
- type2Validator[typeof(Nullable<Decimal>)] =
typeof(NullableDecimalValidator);
+ type2Validator[typeof(Nullable<Decimal>)] =
typeof(DecimalValidator);
type2Validator[typeof(Single)] =
typeof(SingleValidator);
- type2Validator[typeof(Nullable<Single>)] =
typeof(NullableSingleValidator);
+ type2Validator[typeof(Nullable<Single>)] =
typeof(SingleValidator);
type2Validator[typeof(Double)] =
typeof(DoubleValidator);
- type2Validator[typeof(Nullable<Double>)] =
typeof(NullableDoubleValidator);
+ type2Validator[typeof(Nullable<Double>)] =
typeof(DoubleValidator);
type2Validator[typeof(DateTime)] =
typeof(DateTimeValidator);
- type2Validator[typeof(Nullable<DateTime>)] =
typeof(NullableDateTimeValidator);
+ type2Validator[typeof(Nullable<DateTime>)] =
typeof(DateTimeValidator);
}
File [modified]: ValidatorRunner.cs
Delta lines: +0 -67
===================================================================
---
trunk/Components/Validator/Castle.Components.Validator/Validators/NullableDateTimeValidator.cs
2008-08-28 08:49:52 UTC (rev 5296)
+++
trunk/Components/Validator/Castle.Components.Validator/Validators/NullableDateTimeValidator.cs
2008-08-28 09:35:29 UTC (rev 5297)
@@ -1,67 +0,0 @@
-// Copyright 2004-2008 Castle Project - http://www.castleproject.org/
-//
-// 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.
-
-namespace Castle.Components.Validator
-{
- using System;
-
- /// <summary>
- /// This is a meta validator.
- /// It is only useful to test a source content before setting it on the
- /// target instance.
- /// </summary>
- public class NullableDateTimeValidator : AbstractValidator
- {
- /// <summary>
- /// Checks if the <c>fieldValue</c> can be converted to a valid
DateTime.
- /// Null or empty value allowed.
- /// </summary>
- /// <param name="instance">The target type instance</param>
- /// <param name="fieldValue">The property/field value. It can
be null.</param>
- /// <returns>
- /// <c>true</c> if the value is accepted (has passed the
validation test)
- /// </returns>
- public override bool IsValid(object instance, object fieldValue)
- {
- if (fieldValue == null) return true;
-
- string stringValue = fieldValue.ToString();
-
- if (stringValue == String.Empty) return true;
-
- DateTime datetimeValue;
- return DateTime.TryParse(stringValue, out
datetimeValue);
- }
-
- /// <summary>
- /// Gets a value indicating whether this validator supports
browser validation.
- /// </summary>
- /// <value>
- /// <see langword="true"/> if browser validation is
supported; otherwise, <see langword="false"/>.
- /// </value>
- public override bool SupportsBrowserValidation
- {
- get { return true; }
- }
-
- /// <summary>
- /// Returns the key used to internationalize error messages
- /// </summary>
- /// <value></value>
- protected override string MessageKey
- {
- get { return MessageConstants.InvalidDateMessage; }
- }
- }
-}
Directory: /trunk/Components/Validator/Castle.Components.Validator.Tests/
=========================================================================
File [modified]: Castle.Components.Validator.Tests-vs2005.csproj
Delta lines: +2 -8
===================================================================
---
trunk/Components/Validator/Castle.Components.Validator.Tests/Castle.Components.Validator.Tests-vs2008.csproj
2008-08-28 08:49:52 UTC (rev 5296)
+++
trunk/Components/Validator/Castle.Components.Validator.Tests/Castle.Components.Validator.Tests-vs2008.csproj
2008-08-28 09:35:29 UTC (rev 5297)
@@ -2,7 +2,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.21022</ProductVersion>
+ <ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{50BE4C5D-4535-4449-AB5B-8DF92F005386}</ProjectGuid>
<OutputType>Library</OutputType>
@@ -67,12 +67,6 @@
<Compile Include="ValidatorTests\IsGreaterValidatorTestCase.cs" />
<Compile Include="ValidatorTests\NotSameValueValidatorTestCase.cs" />
<Compile Include="ValidatorTests\DateValidatorTestCase.cs" />
- <Compile Include="ValidatorTests\NullableDateTimeValidatorTestCase.cs" />
- <Compile Include="ValidatorTests\NullableDateValidatorTestCase.cs" />
- <Compile Include="ValidatorTests\NullableDecimalValidatorTestCase.cs" />
- <Compile Include="ValidatorTests\NullableDoubleValidatorTestCase.cs" />
- <Compile Include="ValidatorTests\NullableIntegerValidatorTestCase.cs" />
- <Compile Include="ValidatorTests\NullableSingleValidatorTestCase.cs" />
<Compile Include="ValidatorTests\RangeValidatorTestCase.cs" />
<Compile Include="ValidatorTests\DateTimeValidatorTestCase.cs" />
<Compile Include="ValidatorTests\DecimalValidatorTestCase.cs" />
@@ -115,4 +109,4 @@
<Target Name="AfterBuild">
</Target>
-->
-</Project>
+</Project>
File [modified]: Castle.Components.Validator.Tests-vs2008.csproj
Delta lines: +0 -68
===================================================================
---
trunk/Components/Validator/Castle.Components.Validator.Tests/ValidatorTests/NullableDateTimeValidatorTestCase.cs
2008-08-28 08:49:52 UTC (rev 5296)
+++
trunk/Components/Validator/Castle.Components.Validator.Tests/ValidatorTests/NullableDateTimeValidatorTestCase.cs
2008-08-28 09:35:29 UTC (rev 5297)
@@ -1,69 +0,0 @@
-// Copyright 2004-2008 Castle Project - http://www.castleproject.org/
-//
-// 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.
-
-namespace Castle.Components.Validator.Tests.ValidatorTests
-{
- using System;
- using System.Globalization;
- using System.Threading;
- using NUnit.Framework;
-
- [TestFixture]
- public class NullableDateTimeValidatorTestCase
- {
- private NullableDateTimeValidator validator;
- private TestTarget target;
-
- [SetUp]
- public void Init()
- {
- Thread.CurrentThread.CurrentCulture =
- Thread.CurrentThread.CurrentUICulture = new
CultureInfo("en-us");
-
- validator = new NullableDateTimeValidator();
- validator.Initialize(new CachedValidationRegistry(),
typeof(TestTarget).GetProperty("DtField"));
- target = new TestTarget();
- }
-
- [Test]
- public void InvalidDate()
- {
- Assert.IsFalse(validator.IsValid(target, "some"));
- Assert.IsFalse(validator.IsValid(target, "122"));
- Assert.IsFalse(validator.IsValid(target, "99/99/99"));
- Assert.IsFalse(validator.IsValid(target, "99-99-99"));
- }
-
- [Test]
- public void ValidDate()
- {
- Assert.IsTrue(validator.IsValid(target, "01/12/2004"));
- Assert.IsTrue(validator.IsValid(target, "07/16/1979"));
- Assert.IsTrue(validator.IsValid(target,
"2007-01-14T12:05:25"));
- Assert.IsTrue(validator.IsValid(target, null));
- Assert.IsTrue(validator.IsValid(target, ""));
- }
-
- public class TestTarget
- {
- private DateTime dtField;
-
- public DateTime DtField
- {
- get { return dtField; }
- set { dtField = value; }
- }
- }
- }
Directory:
/trunk/Components/Validator/Castle.Components.Validator.Tests/ValidatorTests/
========================================================================================
File [removed]: NullableDateTimeValidatorTestCase.cs
Delta lines: +0 -68
===================================================================
---
trunk/Components/Validator/Castle.Components.Validator.Tests/ValidatorTests/NullableDateValidatorTestCase.cs
2008-08-28 08:49:52 UTC (rev 5296)
+++
trunk/Components/Validator/Castle.Components.Validator.Tests/ValidatorTests/NullableDateValidatorTestCase.cs
2008-08-28 09:35:29 UTC (rev 5297)
@@ -1,69 +0,0 @@
-// Copyright 2004-2008 Castle Project - http://www.castleproject.org/
-//
-// 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.
-
-namespace Castle.Components.Validator.Tests.ValidatorTests
-{
- using System;
- using System.Globalization;
- using System.Threading;
- using NUnit.Framework;
-
- [TestFixture]
- public class NullableDateValidatorTestCase
- {
- private NullableDateValidator validator;
- private TestTarget target;
-
- [SetUp]
- public void Init()
- {
- Thread.CurrentThread.CurrentCulture =
- Thread.CurrentThread.CurrentUICulture = new
CultureInfo("en-us");
-
- validator = new NullableDateValidator();
- validator.Initialize(new CachedValidationRegistry(),
typeof(TestTarget).GetProperty("DtField"));
- target = new TestTarget();
- }
-
- [Test]
- public void InvalidDate()
- {
- Assert.IsFalse(validator.IsValid(target, "some"));
- Assert.IsFalse(validator.IsValid(target, "122"));
- Assert.IsFalse(validator.IsValid(target, "99/99/99"));
- Assert.IsFalse(validator.IsValid(target, "99-99-99"));
- Assert.IsFalse(validator.IsValid(target,
"2007-01-14T12:05:25"));
- }
-
- [Test]
- public void ValidDate()
- {
- Assert.IsTrue(validator.IsValid(target, "01/12/2004"));
- Assert.IsTrue(validator.IsValid(target, "07/16/1979"));
- Assert.IsTrue(validator.IsValid(target, null));
- Assert.IsTrue(validator.IsValid(target, ""));
- }
-
- public class TestTarget
- {
- private DateTime dtField;
-
- public DateTime DtField
- {
- get { return dtField; }
- set { dtField = value; }
- }
- }
- }
File [removed]: NullableDateValidatorTestCase.cs
Delta lines: +0 -65
===================================================================
---
trunk/Components/Validator/Castle.Components.Validator.Tests/ValidatorTests/NullableDecimalValidatorTestCase.cs
2008-08-28 08:49:52 UTC (rev 5296)
+++
trunk/Components/Validator/Castle.Components.Validator.Tests/ValidatorTests/NullableDecimalValidatorTestCase.cs
2008-08-28 09:35:29 UTC (rev 5297)
@@ -1,66 +0,0 @@
-// Copyright 2004-2008 Castle Project - http://www.castleproject.org/
-//
-// 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.
-
-namespace Castle.Components.Validator.Tests.ValidatorTests
-{
- using System.Globalization;
- using System.Threading;
- using NUnit.Framework;
-
- [TestFixture]
- public class NullableDecimalValidatorTestCase
- {
- private NullableDecimalValidator validator;
- private TestTarget target;
-
- [SetUp]
- public void Init()
- {
- Thread.CurrentThread.CurrentCulture =
- Thread.CurrentThread.CurrentUICulture = new
CultureInfo("en-us");
-
- validator = new NullableDecimalValidator();
- validator.Initialize(new CachedValidationRegistry(),
typeof(TestTarget).GetProperty("TargetField"));
- target = new TestTarget();
- }
-
- [Test]
- public void InvalidDouble()
- {
- Assert.IsFalse(validator.IsValid(target, "abc"));
- }
-
- [Test]
- public void ValidDouble()
- {
- Assert.IsTrue(validator.IsValid(target, "100"));
- Assert.IsTrue(validator.IsValid(target, "100.45"));
- Assert.IsTrue(validator.IsValid(target, "-99.8"));
- Assert.IsTrue(validator.IsValid(target, "-99"));
- Assert.IsTrue(validator.IsValid(target, null));
- Assert.IsTrue(validator.IsValid(target, ""));
- }
-
- public class TestTarget
- {
- private double targetField;
-
- public double TargetField
- {
- get { return targetField; }
- set { targetField = value; }
- }
- }
- }
File [removed]: NullableDecimalValidatorTestCase.cs
Delta lines: +0 -65
===================================================================
---
trunk/Components/Validator/Castle.Components.Validator.Tests/ValidatorTests/NullableDoubleValidatorTestCase.cs
2008-08-28 08:49:52 UTC (rev 5296)
+++
trunk/Components/Validator/Castle.Components.Validator.Tests/ValidatorTests/NullableDoubleValidatorTestCase.cs
2008-08-28 09:35:29 UTC (rev 5297)
@@ -1,66 +0,0 @@
-// Copyright 2004-2008 Castle Project - http://www.castleproject.org/
-//
-// 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.
-
-namespace Castle.Components.Validator.Tests.ValidatorTests
-{
- using System.Globalization;
- using System.Threading;
- using NUnit.Framework;
-
- [TestFixture]
- public class NullableDoubleValidatorTestCase
- {
- private NullableDoubleValidator validator;
- private TestTarget target;
-
- [SetUp]
- public void Init()
- {
- Thread.CurrentThread.CurrentCulture =
- Thread.CurrentThread.CurrentUICulture = new
CultureInfo("en-us");
-
- validator = new NullableDoubleValidator();
- validator.Initialize(new CachedValidationRegistry(),
typeof(TestTarget).GetProperty("TargetField"));
- target = new TestTarget();
- }
-
- [Test]
- public void InvalidDouble()
- {
- Assert.IsFalse(validator.IsValid(target, "abc"));
- }
-
- [Test]
- public void ValidDouble()
- {
- Assert.IsTrue(validator.IsValid(target, "100"));
- Assert.IsTrue(validator.IsValid(target, "100.45155"));
- Assert.IsTrue(validator.IsValid(target, "-99.8"));
- Assert.IsTrue(validator.IsValid(target, "-99"));
- Assert.IsTrue(validator.IsValid(target, null));
- Assert.IsTrue(validator.IsValid(target, ""));
- }
-
- public class TestTarget
- {
- private double targetField;
-
- public double TargetField
- {
- get { return targetField; }
- set { targetField = value; }
- }
- }
- }
File [removed]: NullableDoubleValidatorTestCase.cs
Delta lines: +0 -65
===================================================================
---
trunk/Components/Validator/Castle.Components.Validator.Tests/ValidatorTests/NullableIntegerValidatorTestCase.cs
2008-08-28 08:49:52 UTC (rev 5296)
+++
trunk/Components/Validator/Castle.Components.Validator.Tests/ValidatorTests/NullableIntegerValidatorTestCase.cs
2008-08-28 09:35:29 UTC (rev 5297)
@@ -1,66 +0,0 @@
-// Copyright 2004-2008 Castle Project - http://www.castleproject.org/
-//
-// 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.
-
-namespace Castle.Components.Validator.Tests.ValidatorTests
-{
- using System.Globalization;
- using System.Threading;
- using NUnit.Framework;
-
- [TestFixture]
- public class NullableIntegerValidatorTestCase
- {
- private NullableIntegerValidator validator;
- private TestTarget target;
-
- [SetUp]
- public void Init()
- {
- Thread.CurrentThread.CurrentCulture =
- Thread.CurrentThread.CurrentUICulture = new
CultureInfo("en-us");
-
- validator = new NullableIntegerValidator();
- validator.Initialize(new CachedValidationRegistry(),
typeof(TestTarget).GetProperty("TargetField"));
- target = new TestTarget();
- }
-
- [Test]
- public void InvalidInteger()
- {
- Assert.IsFalse(validator.IsValid(target, "abc"));
- Assert.IsFalse(validator.IsValid(target, "100.11"));
- Assert.IsFalse(validator.IsValid(target, "-99.8"));
- }
-
- [Test]
- public void ValidInteger()
- {
- Assert.IsTrue(validator.IsValid(target, "100"));
- Assert.IsTrue(validator.IsValid(target, "-99"));
- Assert.IsTrue(validator.IsValid(target, null));
- Assert.IsTrue(validator.IsValid(target, ""));
- }
-
- public class TestTarget
- {
- private int targetField;
-
- public int TargetField
- {
- get { return targetField; }
- set { targetField = value; }
- }
- }
- }
File [removed]: NullableIntegerValidatorTestCase.cs
Delta lines: +0 -65
===================================================================
---
trunk/Components/Validator/Castle.Components.Validator.Tests/ValidatorTests/NullableSingleValidatorTestCase.cs
2008-08-28 08:49:52 UTC (rev 5296)
+++
trunk/Components/Validator/Castle.Components.Validator.Tests/ValidatorTests/NullableSingleValidatorTestCase.cs
2008-08-28 09:35:29 UTC (rev 5297)
@@ -1,66 +0,0 @@
-// Copyright 2004-2008 Castle Project - http://www.castleproject.org/
-//
-// 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.
-
-namespace Castle.Components.Validator.Tests.ValidatorTests
-{
- using System.Globalization;
- using System.Threading;
- using NUnit.Framework;
-
- [TestFixture]
- public class NullableSingleValidatorTestCase
- {
- private NullableSingleValidator validator;
- private TestTarget target;
-
- [SetUp]
- public void Init()
- {
- Thread.CurrentThread.CurrentCulture =
- Thread.CurrentThread.CurrentUICulture = new
CultureInfo("en-us");
-
- validator = new NullableSingleValidator();
- validator.Initialize(new CachedValidationRegistry(),
typeof(TestTarget).GetProperty("TargetField"));
- target = new TestTarget();
- }
-
- [Test]
- public void InvalidSingle()
- {
- Assert.IsFalse(validator.IsValid(target, "abc"));
- }
-
- [Test]
- public void ValidSingle()
- {
- Assert.IsTrue(validator.IsValid(target, "100"));
- Assert.IsTrue(validator.IsValid(target, "100.11002"));
- Assert.IsTrue(validator.IsValid(target, "-99.8"));
- Assert.IsTrue(validator.IsValid(target, "-99"));
- Assert.IsTrue(validator.IsValid(target, null));
- Assert.IsTrue(validator.IsValid(target, ""));
- }
-
- public class TestTarget
- {
- private double targetField;
-
- public double TargetField
- {
- get { return targetField; }
- set { targetField = value; }
- }
- }
- }
File [removed]: NullableSingleValidatorTestCase.cs
Delta lines: +0 -0
===================================================================
Directory: /trunk/Components/Validator/Castle.Components.Validator/Validators/
==============================================================================
File [removed]: NullableDateTimeValidator.cs
Delta lines: +0 -99
===================================================================
---
trunk/Components/Validator/Castle.Components.Validator/Validators/NullableDateValidator.cs
2008-08-28 08:49:52 UTC (rev 5296)
+++
trunk/Components/Validator/Castle.Components.Validator/Validators/NullableDateValidator.cs
2008-08-28 09:35:29 UTC (rev 5297)
@@ -1,99 +0,0 @@
-// Copyright 2004-2008 Castle Project - http://www.castleproject.org/
-//
-// 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.
-
-namespace Castle.Components.Validator
-{
- using System;
- using System.Collections;
-
- /// <summary>
- /// This is a meta validator.
- /// It is only useful to test a source content before setting it on the
- /// target instance.
- /// </summary>
- public class NullableDateValidator : AbstractValidator
- {
- /// <summary>
- /// Checks if the <c>fieldValue</c> can be converted to a valid
Date (so no time part).
- /// Null or empty value allowed.
- /// </summary>
- /// <param name="instance">The target type instance</param>
- /// <param name="fieldValue">The property/field value. It can
be null.</param>
- /// <returns>
- /// <c>true</c> if the value is accepted (has passed the
validation test)
- /// </returns>
- public override bool IsValid(object instance, object fieldValue)
- {
- if (fieldValue == null) return true;
-
- string stringValue = fieldValue.ToString();
-
- if (stringValue == String.Empty) return true;
-
- DateTime datetimeValue;
- bool valid = DateTime.TryParse(stringValue, out
datetimeValue);
-
- if (valid)
- return IsDateOnly(datetimeValue);
-
- return valid;
- }
-
- /// <summary>
- /// Gets a value indicating whether this validator supports
browser validation.
- /// </summary>
- /// <value>
- /// <see langword="true"/> if browser validation is
supported; otherwise, <see langword="false"/>.
- /// </value>
- public override bool SupportsBrowserValidation
- {
- get { return true; }
- }
-
- /// <summary>
- /// Applies the browser validation by setting up one or
- /// more input rules on <see
cref="IBrowserValidationGenerator"/>.
- /// </summary>
- /// <param name="config">The config.</param>
- /// <param name="inputType">Type of the input.</param>
- /// <param name="generator">The generator.</param>
- /// <param name="attributes">The attributes.</param>
- /// <param name="target">The target.</param>
- public override void
ApplyBrowserValidation(BrowserValidationConfiguration config, InputElementType
inputType,
-
IBrowserValidationGenerator generator, IDictionary attributes,
- string target)
- {
- generator.SetDate(target, BuildErrorMessage());
- }
-
- /// <summary>
- /// Returns the key used to internationalize error messages
- /// </summary>
- /// <value></value>
- protected override string MessageKey
- {
- get { return MessageConstants.InvalidDateMessage; }
- }
-
- /// <summary>
- /// Check if only date given (so no time part)
- /// </summary>
- /// <param name="date">The date to check</param>
- /// <returns><see langword="true"/>If Date only; otherwise,
<see langword="false"/>.</returns>
- private static bool IsDateOnly(DateTime date)
- {
- return (date.TimeOfDay.TotalMilliseconds == 0);
- }
- }
-}
File [removed]: NullableDateValidator.cs
Delta lines: +0 -84
===================================================================
---
trunk/Components/Validator/Castle.Components.Validator/Validators/NullableDecimalValidator.cs
2008-08-28 08:49:52 UTC (rev 5296)
+++
trunk/Components/Validator/Castle.Components.Validator/Validators/NullableDecimalValidator.cs
2008-08-28 09:35:29 UTC (rev 5297)
@@ -1,84 +0,0 @@
-// Copyright 2004-2008 Castle Project - http://www.castleproject.org/
-//
-// 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.
-
-namespace Castle.Components.Validator
-{
- using System;
- using System.Collections;
-
- /// <summary>
- /// This is a meta validator.
- /// It is only useful to test a source content before setting it on the
- /// target instance.
- /// </summary>
- public class NullableDecimalValidator : AbstractValidator
- {
- /// <summary>
- /// Checks if the <c>fieldValue</c> can be converted to a valid
Decimal.
- /// Null or empty value allowed.
- /// </summary>
- /// <param name="instance">The target type instance</param>
- /// <param name="fieldValue">The property/field value. It can
be null.</param>
- /// <returns>
- /// <c>true</c> if the value is accepted (has passed the
validation test)
- /// </returns>
- public override bool IsValid(object instance, object fieldValue)
- {
- if (fieldValue == null) return true;
-
- string stringValue = fieldValue.ToString();
-
- if (stringValue == String.Empty) return true;
-
- Decimal decimalValue;
- return Decimal.TryParse(stringValue, out decimalValue);
- }
-
- /// <summary>
- /// Gets a value indicating whether this validator supports
browser validation.
- /// </summary>
- /// <value>
- /// <see langword="true"/> if browser validation is
supported; otherwise, <see langword="false"/>.
- /// </value>
- public override bool SupportsBrowserValidation
- {
- get { return true; }
- }
-
- /// <summary>
- /// Applies the browser validation by setting up one or
- /// more input rules on <see
cref="IBrowserValidationGenerator"/>.
- /// </summary>
- /// <param name="config">The config.</param>
- /// <param name="inputType">Type of the input.</param>
- /// <param name="generator">The generator.</param>
- /// <param name="attributes">The attributes.</param>
- /// <param name="target">The target.</param>
- public override void
ApplyBrowserValidation(BrowserValidationConfiguration config, InputElementType
inputType,
-
IBrowserValidationGenerator generator, IDictionary attributes,
- string target)
- {
- generator.SetNumberOnly(target, BuildErrorMessage());
- }
-
- /// <summary>
- /// Returns the key used to internationalize error messages
- /// </summary>
- /// <value></value>
- protected override string MessageKey
- {
- get { return MessageConstants.InvalidDecimalMessage; }
- }
- }
-}
File [removed]: NullableDecimalValidator.cs
Delta lines: +0 -84
===================================================================
---
trunk/Components/Validator/Castle.Components.Validator/Validators/NullableDoubleValidator.cs
2008-08-28 08:49:52 UTC (rev 5296)
+++
trunk/Components/Validator/Castle.Components.Validator/Validators/NullableDoubleValidator.cs
2008-08-28 09:35:29 UTC (rev 5297)
@@ -1,84 +0,0 @@
-// Copyright 2004-2008 Castle Project - http://www.castleproject.org/
-//
-// 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.
-
-namespace Castle.Components.Validator
-{
- using System;
- using System.Collections;
-
- /// <summary>
- /// This is a meta validator.
- /// It is only useful to test a source content before setting it on the
- /// target instance.
- /// </summary>
- public class NullableDoubleValidator : AbstractValidator
- {
- /// <summary>
- /// Checks if the <c>fieldValue</c> can be converted to a valid
Double.
- /// Null or empty value allowed.
- /// </summary>
- /// <param name="instance">The target type instance</param>
- /// <param name="fieldValue">The property/field value. It can
be null.</param>
- /// <returns>
- /// <c>true</c> if the value is accepted (has passed the
validation test)
- /// </returns>
- public override bool IsValid(object instance, object fieldValue)
- {
- if (fieldValue == null) return true;
-
- string stringValue = fieldValue.ToString();
-
- if (stringValue == String.Empty) return true;
-
- Double doubleValue;
- return Double.TryParse(stringValue, out doubleValue);
- }
-
- /// <summary>
- /// Gets a value indicating whether this validator supports
browser validation.
- /// </summary>
- /// <value>
- /// <see langword="true"/> if browser validation is
supported; otherwise, <see langword="false"/>.
- /// </value>
- public override bool SupportsBrowserValidation
- {
- get { return true; }
- }
-
- /// <summary>
- /// Applies the browser validation by setting up one or
- /// more input rules on <see
cref="IBrowserValidationGenerator"/>.
- /// </summary>
- /// <param name="config">The config.</param>
- /// <param name="inputType">Type of the input.</param>
- /// <param name="generator">The generator.</param>
- /// <param name="attributes">The attributes.</param>
- /// <param name="target">The target.</param>
- public override void
ApplyBrowserValidation(BrowserValidationConfiguration config, InputElementType
inputType,
-
IBrowserValidationGenerator generator, IDictionary attributes,
- string target)
- {
- generator.SetNumberOnly(target, BuildErrorMessage());
- }
-
- /// <summary>
- /// Returns the key used to internationalize error messages
- /// </summary>
- /// <value></value>
- protected override string MessageKey
- {
- get { return MessageConstants.InvalidDoubleMessage; }
- }
- }
-}
File [removed]: NullableDoubleValidator.cs
Delta lines: +0 -96
===================================================================
---
trunk/Components/Validator/Castle.Components.Validator/Validators/NullableIntegerValidator.cs
2008-08-28 08:49:52 UTC (rev 5296)
+++
trunk/Components/Validator/Castle.Components.Validator/Validators/NullableIntegerValidator.cs
2008-08-28 09:35:29 UTC (rev 5297)
@@ -1,97 +0,0 @@
-// Copyright 2004-2008 Castle Project - http://www.castleproject.org/
-//
-// 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.
-
-namespace Castle.Components.Validator
-{
- using System;
- using System.Collections;
-
- /// <summary>
- /// This is a meta validator.
- /// It is only useful to test a source content before setting it on the
- /// target instance.
- /// </summary>
- public class NullableIntegerValidator : AbstractValidator
- {
- /// <summary>
- /// Checks if the <c>fieldValue</c> can be converted to a valid
Integer.
- /// Null or empty value allowed.
- /// </summary>
- /// <param name="instance">The target type instance</param>
- /// <param name="fieldValue">The property/field value. It can
be null.</param>
- /// <returns>
- /// <c>true</c> if the value is accepted (has passed the
validation test)
- /// </returns>
- public override bool IsValid(object instance, object fieldValue)
- {
- if (fieldValue == null) return true;
-
- string stringValue = fieldValue.ToString();
-
- if (stringValue == String.Empty) return true;
-
- if (Property != null && Property.PropertyType ==
typeof(Nullable<Int16>))
- {
- Int16 intValue;
- return Int16.TryParse(stringValue, out
intValue);
- }
- else if (Property != null && Property.PropertyType ==
typeof(Nullable<Int64>))
- {
- Int64 intValue;
- return Int64.TryParse(stringValue, out
intValue);
- }
- else
- {
- Int32 intValue;
- return Int32.TryParse(stringValue, out
intValue);
- }
- }
-
- /// <summary>
- /// Gets a value indicating whether this validator supports
browser validation.
- /// </summary>
- /// <value>
- /// <see langword="true"/> if browser validation is
supported; otherwise, <see langword="false"/>.
- /// </value>
- public override bool SupportsBrowserValidation
- {
- get { return true; }
- }
-
- /// <summary>
- /// Applies the browser validation by setting up one or
- /// more input rules on <see
cref="IBrowserValidationGenerator"/>.
- /// </summary>
- /// <param name="config">The config.</param>
- /// <param name="inputType">Type of the input.</param>
- /// <param name="generator">The generator.</param>
- /// <param name="attributes">The attributes.</param>
- /// <param name="target">The target.</param>
- public override void
ApplyBrowserValidation(BrowserValidationConfiguration config, InputElementType
inputType,
-
IBrowserValidationGenerator generator, IDictionary attributes,
- string target)
- {
- generator.SetDigitsOnly(target, BuildErrorMessage());
- }
-
- /// <summary>
- /// Returns the key used to internationalize error messages
- /// </summary>
- /// <value></value>
- protected override string MessageKey
- {
- get { return MessageConstants.InvalidIntegerMessage; }
- }
- }
File [removed]: NullableIntegerValidator.cs
Delta lines: +0 -84
===================================================================
---
trunk/Components/Validator/Castle.Components.Validator/Validators/NullableSingleValidator.cs
2008-08-28 08:49:52 UTC (rev 5296)
+++
trunk/Components/Validator/Castle.Components.Validator/Validators/NullableSingleValidator.cs
2008-08-28 09:35:29 UTC (rev 5297)
@@ -1,84 +0,0 @@
-// Copyright 2004-2008 Castle Project - http://www.castleproject.org/
-//
-// 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.
-
-namespace Castle.Components.Validator
-{
- using System;
- using System.Collections;
-
- /// <summary>
- /// This is a meta validator.
- /// It is only useful to test a source content before setting it on the
- /// target instance.
- /// </summary>
- public class NullableSingleValidator : AbstractValidator
- {
- /// <summary>
- /// Checks if the <c>fieldValue</c> can be converted to a valid
Single.
- /// Null or empty value allowed.
- /// </summary>
- /// <param name="instance">The target type instance</param>
- /// <param name="fieldValue">The property/field value. It can
be null.</param>
- /// <returns>
- /// <c>true</c> if the value is accepted (has passed the
validation test)
- /// </returns>
- public override bool IsValid(object instance, object fieldValue)
- {
- if (fieldValue == null) return true;
-
- string stringValue = fieldValue.ToString();
-
- if (stringValue == String.Empty) return true;
-
- Single singleValue;
- return Single.TryParse(stringValue, out singleValue);
- }
-
- /// <summary>
- /// Gets a value indicating whether this validator supports
browser validation.
- /// </summary>
- /// <value>
- /// <see langword="true"/> if browser validation is
supported; otherwise, <see langword="false"/>.
- /// </value>
- public override bool SupportsBrowserValidation
- {
- get { return true; }
- }
-
- /// <summary>
- /// Applies the browser validation by setting up one or
- /// more input rules on <see
cref="IBrowserValidationGenerator"/>.
- /// </summary>
- /// <param name="config">The config.</param>
- /// <param name="inputType">Type of the input.</param>
- /// <param name="generator">The generator.</param>
- /// <param name="attributes">The attributes.</param>
- /// <param name="target">The target.</param>
- public override void
ApplyBrowserValidation(BrowserValidationConfiguration config, InputElementType
inputType,
-
IBrowserValidationGenerator generator, IDictionary attributes,
- string target)
- {
- generator.SetDigitsOnly(target, BuildErrorMessage());
- }
-
- /// <summary>
- /// Returns the key used to internationalize error messages
- /// </summary>
- /// <value></value>
- protected override string MessageKey
- {
- get { return MessageConstants.InvalidSingleMessage; }
- }
- }
-}
File [removed]: NullableSingleValidator.cs
Delta lines: +0 -6
===================================================================
---
trunk/Components/Validator/Castle.Components.Validator.Tests/Castle.Components.Validator.Tests-vs2005.csproj
2008-08-28 08:49:52 UTC (rev 5296)
+++
trunk/Components/Validator/Castle.Components.Validator.Tests/Castle.Components.Validator.Tests-vs2005.csproj
2008-08-28 09:35:29 UTC (rev 5297)
@@ -59,12 +59,6 @@
<Compile Include="ValidatorTests\IsGreaterValidatorTestCase.cs" />
<Compile Include="ValidatorTests\NotSameValueValidatorTestCase.cs" />
<Compile Include="ValidatorTests\DateValidatorTestCase.cs" />
- <Compile Include="ValidatorTests\NullableDateTimeValidatorTestCase.cs" />
- <Compile Include="ValidatorTests\NullableDateValidatorTestCase.cs" />
- <Compile Include="ValidatorTests\NullableDecimalValidatorTestCase.cs" />
- <Compile Include="ValidatorTests\NullableDoubleValidatorTestCase.cs" />
- <Compile Include="ValidatorTests\NullableIntegerValidatorTestCase.cs" />
- <Compile Include="ValidatorTests\NullableSingleValidatorTestCase.cs" />
<Compile Include="ValidatorTests\RangeValidatorTestCase.cs" />
<Compile Include="ValidatorTests\DateTimeValidatorTestCase.cs" />
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Castle Project Commits" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/castle-project-commits?hl=en
-~----------~----~----~----~------~----~------~--~---