Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/114 comparing two properties #131

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
fd85f84
Removed unused strategy in ValitRule
GooRiOn Nov 19, 2017
24c0f76
Added support for nested objects
GooRiOn Nov 19, 2017
cf19391
removed message provider from nested object valit rule
GooRiOn Nov 22, 2017
0ce93d4
Added internal Valitator, added extension for transforming ValitRules…
GooRiOn Nov 22, 2017
3593c10
Added unit tests for nested objects and valitator
GooRiOn Nov 22, 2017
9c40449
Made Tags in NestedObjectValitRul explicit
GooRiOn Nov 22, 2017
89961d8
fix typo
timdeschryver Nov 26, 2017
ad29474
arrange test similar like the other tests
timdeschryver Nov 26, 2017
07b3189
add boolean support
timdeschryver Nov 26, 2017
9824a9d
add required
timdeschryver Nov 26, 2017
47ef7e4
HasValue checks for nullables
timdeschryver Nov 27, 2017
64436cf
fix indention similar to other files
timdeschryver Nov 27, 2017
7dce801
Issue 117: Added support for variable messages
Nov 27, 2017
c735467
Minor stylechange
Nov 28, 2017
493ee61
Replaced default value for function to be empty string
Nov 28, 2017
1aa2a6a
remove spaces in gitignore
timdeschryver Nov 28, 2017
6de4de4
add reference to watcher tools
timdeschryver Nov 28, 2017
2d6ab7b
document dotnet watch test
timdeschryver Nov 28, 2017
7189ec3
add gitattributes
timdeschryver Nov 28, 2017
4116619
Added missing Required method for string type
GooRiOn Nov 29, 2017
5d0059e
Revert 4116619e2f0e710d0022e73766e2ce702ae350c6
GooRiOn Nov 29, 2017
b8e61cc
Added missing Required method on string type.
GooRiOn Nov 29, 2017
c52618f
PR fixes
GooRiOn Dec 2, 2017
7c4c23a
Changed NullValue to EmptyValue in Empty string tests for Required
GooRiOn Dec 2, 2017
b3660c8
Added first version of collection valit rule
GooRiOn Nov 23, 2017
c6cb9ae
Added support for collections
GooRiOn Nov 26, 2017
a8453d1
Fixed typos
GooRiOn Nov 29, 2017
8c8b73d
Changed NestedObjectValitRule so it uses Valitator inside
GooRiOn Nov 29, 2017
421eeeb
Made Tags public in all IValitRule implementations just for a consist…
GooRiOn Nov 29, 2017
c089d1c
PR fixes
GooRiOn Dec 2, 2017
c36adfd
added possibility to compare two properties
paw3lx Dec 2, 2017
e0dd752
add editorconfig
timdeschryver Nov 28, 2017
6a5a4f7
add default format conventions
timdeschryver Nov 29, 2017
395ce14
autofix files with eclint
timdeschryver Dec 2, 2017
148679b
call GetAllEnsureRules() before validation
paw3lx Dec 3, 2017
856f4a6
Merge branch 'develop' of https://github.com/valit-stack/Valit into f…
paw3lx Dec 3, 2017
898ff25
removed whitespaces, added expression-bodied members
paw3lx Dec 4, 2017
1eb3bfb
removed unnecessary checking in test
paw3lx Dec 4, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
root = true

[*]
charset = utf-8
end_of_line = crlf
indent_style = space

[*.cs]
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
dotnet_sort_system_directives_first = true
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch= true
csharp_new_line_before_finally= true
csharp_new_line_before_members_in_object_initializers= true
csharp_new_line_before_members_in_anonymous_types= true
csharp_new_line_between_query_expression_clauses= true
csharp_indent_case_contents= true
csharp_indent_switch_labels= true
csharp_indent_labels = no_change
csharp_space_after_cast = false
csharp_space_after_keywords_in_control_flow_statements= true
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_preserve_single_line_statements= true
csharp_preserve_single_line_blocks= true

[*.sln]
indent_style = tab

[*.{csproj, yml, config, cake}]
indent_style = space
indent_size = 2

[*.md]
trim_trailing_whitespace = false
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* text=auto

*.cs text diff=csharp eol=crlf
*.sln text merge=union eol=crlf
*.csproj text merge=union eol=crlf
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@ __pycache__/
*.pyc

# Cake - Uncomment if you are using it
tools/**
!tools/packages.config
tools/**
!tools/packages.config

# Tabs Studio
*.tss
Expand All @@ -312,5 +312,5 @@ __pycache__/
*.odx.cs
*.xsd.cs

# diff
*.orig
# diff
*.orig
100 changes: 50 additions & 50 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceRoot}/tests/Valit.Tests/bin/Debug/netcoreapp2.0/Valit.Tests.dll",
"args": [],
"cwd": "${workspaceRoot}",
"stopAtEntry": false,
"console": "internalConsole"
},
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceRoot}/tests/Valit.Tests/bin/Debug/netcoreapp2.0/Valit.Tests.dll",
"args": [],
"cwd": "${workspaceRoot}",
"stopAtEntry": false,
"launchBrowser": {
"enabled": true,
"args": "${auto-detect-url}",
"windows": {
"command": "cmd.exe",
"args": "/C start ${auto-detect-url}"
},
"osx": {
"command": "open"
},
"linux": {
"command": "xdg-open"
}
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceRoot}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceRoot}/tests/Valit.Tests/bin/Debug/netcoreapp2.0/Valit.Tests.dll",
"args": [],
"cwd": "${workspaceRoot}",
"stopAtEntry": false,
"console": "internalConsole"
},
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceRoot}/tests/Valit.Tests/bin/Debug/netcoreapp2.0/Valit.Tests.dll",
"args": [],
"cwd": "${workspaceRoot}",
"stopAtEntry": false,
"launchBrowser": {
"enabled": true,
"args": "${auto-detect-url}",
"windows": {
"command": "cmd.exe",
"args": "/C start ${auto-detect-url}"
},
"osx": {
"command": "open"
},
"linux": {
"command": "xdg-open"
}
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceRoot}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
30 changes: 15 additions & 15 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"taskName": "build",
"command": "dotnet build",
"type": "shell",
"group": "build",
"presentation": {
"reveal": "silent"
},
"problemMatcher": "$msCompile"
}
]
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"taskName": "build",
"command": "dotnet build",
"type": "shell",
"group": "build",
"presentation": {
"reveal": "silent"
},
"problemMatcher": "$msCompile"
}
]
}
9 changes: 7 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ When you're done make sure all tests passess. Navigate to the ```Valit.Tests```
dotnet test
```

You can also run the following command for continuous testing:
```
dotnet watch test // this will compile the project and rerun the tests on every file change
```

Alternatively, you can use our **Cake script** which is placed in the root folder. Navigate there and run:
```
./build.sh //on Unix
Expand All @@ -63,7 +68,7 @@ When the code is stable, you can submit your changes by creating a pull request.
git push origin <name_of_your_branch>
```

Then go to the **GitHub -> Pull Request -> New Pull Request**.
Then go to the **GitHub -> Pull Request -> New Pull Request**.
Select **develop** as base and your branch as compare. We provide default template for PR description:

![PR_Template](http://foreverframe.net/wp-content/uploads/2017/09/Screen-Shot-2017-09-27-at-21.16.02.png)
Expand All @@ -86,7 +91,7 @@ Each PR must fulfill certain conditions before it can be merged:

If some of the above won't be fulfilled (due to change request or some mistake) simply fix it locally on your machine, create new commit and push it to origin. This will update the exisitng PR and will kick off all checks again.

If everything will be fine, your changes will be merged into develop, branch will be deleted and related issue will be closed.
If everything will be fine, your changes will be merged into develop, branch will be deleted and related issue will be closed.

# WELL DONE AND THANK YOU VERY MUCH!

Expand Down
2 changes: 1 addition & 1 deletion Valit.sln
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26730.16
Expand Down
48 changes: 24 additions & 24 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,38 @@ var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");

Task("dotnet-restore")
.Does(() =>
{
DotNetCoreRestore("./Valit.sln");
});
.Does(() =>
{
DotNetCoreRestore("./Valit.sln");
});

Task("dotnet-build")
.IsDependentOn("dotnet-restore")
.Does(() =>
{
DotNetCoreBuild("./Valit.sln", new DotNetCoreBuildSettings
{
Configuration = configuration,
MSBuildSettings = new DotNetCoreMSBuildSettings
{
TreatAllWarningsAs = MSBuildTreatAllWarningsAs.Error
}
});
});
.IsDependentOn("dotnet-restore")
.Does(() =>
{
DotNetCoreBuild("./Valit.sln", new DotNetCoreBuildSettings
{
Configuration = configuration,
MSBuildSettings = new DotNetCoreMSBuildSettings
{
TreatAllWarningsAs = MSBuildTreatAllWarningsAs.Error
}
});
});

Task("run-xunit-tests")
.IsDependentOn("dotnet-build")
.Does(() =>
{
var settings = new DotNetCoreTestSettings
.IsDependentOn("dotnet-build")
.Does(() =>
{
var settings = new DotNetCoreTestSettings
{
Configuration = configuration
Configuration = configuration
};

DotNetCoreTest("./tests/Valit.Tests/Valit.Tests.csproj", settings);
});
DotNetCoreTest("./tests/Valit.Tests/Valit.Tests.csproj", settings);
});

Task("Default")
.IsDependentOn("run-xunit-tests");
.IsDependentOn("run-xunit-tests");

RunTarget(target);
2 changes: 1 addition & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ if(-Not $SkipToolPackageRestore.IsPresent) {
# Check for changes in packages.config and remove installed tools if true.
[string] $md5Hash = MD5HashFile($PACKAGES_CONFIG)
if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or
($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) {
($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) {
Write-Verbose -Message "Missing or changed package.config hash..."
Remove-Item * -Recurse -Exclude packages.config,nuget.exe
}
Expand Down
4 changes: 2 additions & 2 deletions src/Valit/CompleteValitStrategy.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
namespace Valit
namespace Valit
{
public class CompleteValitStrategy : IValitStrategy
{
public void Fail<TObject>(IValitRule<TObject> rule, IValitResult result, out bool cancel)
public void Fail<TObject>(IValitRule<TObject> rule, IValitResult result, out bool cancel)
where TObject : class
{
cancel = false;
Expand Down
18 changes: 11 additions & 7 deletions src/Valit/Errors/ValitRuleError.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
using System;

namespace Valit.Errors
{
internal class ValitRuleError
{
public string Message { get; }
private readonly Func<string> _messageFunc;
public string Message => _messageFunc();
public int? ErrorCode { get; }

private ValitRuleError(string message)
private ValitRuleError(Func<string> messageFunc)
{
Message = message;
_messageFunc = messageFunc;
}

private ValitRuleError(int errorCode)
{
ErrorCode = errorCode;
_messageFunc = () => string.Empty;
}

public static ValitRuleError CreateForMessage(string message)
=> new ValitRuleError(message);
public static ValitRuleError CreateForMessage(Func<string> messageFunc)
=> new ValitRuleError(messageFunc);

public static ValitRuleError CreateForErrorCode(int errorCode)
=> new ValitRuleError(errorCode);
=> new ValitRuleError(errorCode);
}
}
}
4 changes: 2 additions & 2 deletions src/Valit/Exceptions/SemanticExceptions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;

namespace Valit.Exceptions
{
Expand All @@ -8,6 +8,6 @@ public static ValitException NullDereferenced(string message)
=> throw new ValitException(message, new ArgumentNullException());

public static ValitException NullDereferenced()
=> throw new ValitException("Null dereferenced", new ArgumentNullException());
=> throw new ValitException("Null dereferenced", new ArgumentNullException());
}
}
2 changes: 1 addition & 1 deletion src/Valit/Exceptions/ValitExceptionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ internal static void ThrowIfNull<T>(this T @object, string message)
}
}
}
}
}
4 changes: 2 additions & 2 deletions src/Valit/Exceptions/ValitExceptionMessages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ namespace Valit.Exceptions
internal static class ValitExceptionMessages
{
public static string NullRule => "Valit rule is null";
public static string NullPredicate => "Given predicate is null";
public static string NullPredicate => "Given predicate is null";
}
}
}
Loading