Skip to content

Commit

Permalink
Refactored Enums to be in their namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Alberto Carbonell Rubio committed Sep 17, 2021
1 parent c25447e commit a94cf84
Show file tree
Hide file tree
Showing 16 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion DotnetToolset.Patterns/Dddd/Enums/RuleType.cs
@@ -1,4 +1,4 @@
namespace DotnetToolset.Patterns.Dddd.Interfaces
namespace DotnetToolset.Patterns.Dddd.Enums
{
/// <summary>
/// Types of rules
Expand Down
@@ -1,6 +1,7 @@
using DotnetToolset.ExtensionMethods;
using DotnetToolset.Patterns.Dddd.Interfaces;
using System.Collections.Generic;
using DotnetToolset.Patterns.Dddd.Enums;
using Res = DotnetToolset.Patterns.Resources.Literals;

namespace DotnetToolset.Patterns.Dddd.Implementations.Rules
Expand All @@ -11,8 +12,7 @@ public class CurrencyRule : IRule
/// <summary>
/// Constructor to set the rule value
/// </summary>
/// <param name="amount"></param>
public CurrencyRule()
public CurrencyRule()
{
Rule = new KeyValuePair<RuleType, object>(RuleType.Currency, null);
}
Expand All @@ -28,13 +28,15 @@ public CurrencyRule()
/// <param name="value">Data to be validated</param>
/// <returns>True if rule passed and an optional error message</returns>
public (bool isValid, string errorMessage) Validate(object value)
{
if (value != null && (decimal)value >= 0)
{
if (value != null && (decimal)value >= 0)
{
return (true, null);
}

return (false, Res.p_RuleCurrencyNotPassed.ParseParameters(new object[] { value?.ToString(), (decimal)value }));
}
if (value != null)
return (false,
Res.p_RuleCurrencyNotPassed.ParseParameters(new object[] { value?.ToString(), (decimal)value }));
}
}
}
@@ -1,5 +1,6 @@
using DotnetToolset.Patterns.Dddd.Interfaces;
using System.Collections.Generic;
using DotnetToolset.Patterns.Dddd.Enums;

namespace DotnetToolset.Patterns.Dddd.Implementations.Rules
{
Expand Down
@@ -1,5 +1,6 @@
using DotnetToolset.Patterns.Dddd.Interfaces;
using System.Collections.Generic;
using DotnetToolset.Patterns.Dddd.Enums;
using Res = DotnetToolset.Patterns.Resources.Literals;

namespace DotnetToolset.Patterns.Dddd.Implementations.Rules
Expand Down Expand Up @@ -27,7 +28,7 @@ public IsIntegerRule()
/// <returns>True if rule passed and an optional error message</returns>
public (bool isValid, string errorMessage) Validate(object value)
{
if (value != null && int.TryParse(value.ToString(), out int parsedValue))
if (value != null && int.TryParse(value.ToString(), out _))
{
return (true, null);
}
Expand Down
@@ -1,5 +1,6 @@
using DotnetToolset.Patterns.Dddd.Interfaces;
using System.Collections.Generic;
using DotnetToolset.Patterns.Dddd.Enums;
using Res = DotnetToolset.Patterns.Resources.Literals;

namespace DotnetToolset.Patterns.Dddd.Implementations.Rules
Expand Down
@@ -1,5 +1,6 @@
using DotnetToolset.Patterns.Dddd.Interfaces;
using System.Collections.Generic;
using DotnetToolset.Patterns.Dddd.Enums;

namespace DotnetToolset.Patterns.Dddd.Implementations.Rules
{
Expand Down
@@ -1,6 +1,7 @@
using DotnetToolset.ExtensionMethods;
using DotnetToolset.Patterns.Dddd.Interfaces;
using System.Collections.Generic;
using DotnetToolset.Patterns.Dddd.Enums;
using Res = DotnetToolset.Patterns.Resources.Literals;

namespace DotnetToolset.Patterns.Dddd.Implementations.Rules
Expand Down
@@ -1,6 +1,7 @@
using DotnetToolset.ExtensionMethods;
using DotnetToolset.Patterns.Dddd.Interfaces;
using System.Collections.Generic;
using DotnetToolset.Patterns.Dddd.Enums;
using Res = DotnetToolset.Patterns.Resources.Literals;

namespace DotnetToolset.Patterns.Dddd.Implementations.Rules
Expand Down
@@ -1,6 +1,7 @@
using DotnetToolset.ExtensionMethods;
using DotnetToolset.Patterns.Dddd.Interfaces;
using System.Collections.Generic;
using DotnetToolset.Patterns.Dddd.Enums;
using Res = DotnetToolset.Patterns.Resources.Literals;

namespace DotnetToolset.Patterns.Dddd.Implementations.Rules
Expand Down
@@ -1,6 +1,7 @@
using DotnetToolset.ExtensionMethods;
using DotnetToolset.Patterns.Dddd.Interfaces;
using System.Collections.Generic;
using DotnetToolset.Patterns.Dddd.Enums;
using Res = DotnetToolset.Patterns.Resources.Literals;

namespace DotnetToolset.Patterns.Dddd.Implementations.Rules
Expand Down
@@ -1,6 +1,7 @@
using DotnetToolset.ExtensionMethods;
using DotnetToolset.Patterns.Dddd.Interfaces;
using System.Collections.Generic;
using DotnetToolset.Patterns.Dddd.Enums;
using Res = DotnetToolset.Patterns.Resources.Literals;

namespace DotnetToolset.Patterns.Dddd.Implementations.Rules
Expand Down
@@ -1,8 +1,8 @@
using DotnetToolset.ExtensionMethods;
using DotnetToolset.Patterns.Dddd.Interfaces;
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using DotnetToolset.Patterns.Dddd.Enums;
using Res = DotnetToolset.Patterns.Resources.Literals;

namespace DotnetToolset.Patterns.Dddd.Implementations.Rules
Expand Down Expand Up @@ -43,12 +43,12 @@ public RegexRule(string regex, bool skipWhenEmpty = false)
return (true, Res.p_RuleRegexSkipped.ParseParameter(value.ToString()));
}

if (!String.IsNullOrEmpty((string)value) && match.Success)
if (!string.IsNullOrEmpty((string)value) && match.Success)
{
return (true, null);
}

return (false, Res.p_RuleRegexNotPassed.ParseParameters(new[] { value?.ToString(), Rule.Value }));
return (false, Res.p_RuleRegexNotPassed.ParseParameters(new[] { value.ToString(), Rule.Value }));
}
}
}
1 change: 1 addition & 0 deletions DotnetToolset.Patterns/Dddd/Interfaces/IRule.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using DotnetToolset.Patterns.Dddd.Enums;

namespace DotnetToolset.Patterns.Dddd.Interfaces
{
Expand Down
1 change: 1 addition & 0 deletions DotnetToolset.Patterns/Dddd/Interfaces/IRuleset.cs
Expand Up @@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using DotnetToolset.Patterns.Dddd.Enums;

namespace DotnetToolset.Patterns.Dddd.Interfaces
{
Expand Down
1 change: 1 addition & 0 deletions DotnetToolset.Patterns/Dddd/Interfaces/IRulesetSubject.cs
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using DotnetToolset.Patterns.Dddd.Enums;

namespace DotnetToolset.Patterns.Dddd.Interfaces
{
Expand Down
2 changes: 1 addition & 1 deletion DotnetToolset.Patterns/DotnetToolset.Patterns.csproj
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<RootNamespace>DotnetToolset.Patterns</RootNamespace>
<Version>0.13.0</Version>
<Version>0.13.1</Version>
<Authors>Ahead Labs, S.L.</Authors>
<Description>Opinionated miscellaneous patterns for multilayered .NET projects.</Description>
<Copyright>Ahead Labs, S.L.</Copyright>
Expand Down

0 comments on commit a94cf84

Please sign in to comment.