{"id":17453527,"url":"https://github.com/jonsequitur/its.validation","last_synced_at":"2025-04-19T16:06:55.379Z","repository":{"id":23024658,"uuid":"26377230","full_name":"jonsequitur/Its.Validation","owner":"jonsequitur","description":"A C# library for composing your core business rules and freeing them from framework-specific validation.","archived":false,"fork":false,"pushed_at":"2016-05-24T00:55:52.000Z","size":365,"stargazers_count":17,"open_issues_count":2,"forks_count":5,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-13T16:06:17.219Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonsequitur.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-08T22:43:43.000Z","updated_at":"2024-02-09T09:06:15.000Z","dependencies_parsed_at":"2022-08-21T17:50:54.802Z","dependency_job_id":null,"html_url":"https://github.com/jonsequitur/Its.Validation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonsequitur%2FIts.Validation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonsequitur%2FIts.Validation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonsequitur%2FIts.Validation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonsequitur%2FIts.Validation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonsequitur","download_url":"https://codeload.github.com/jonsequitur/Its.Validation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249733358,"owners_count":21317542,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-18T00:43:13.520Z","updated_at":"2025-04-19T16:06:55.332Z","avatar_url":"https://github.com/jonsequitur.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"### A C# library for composing your core business rules and freeing them from framework-specific validation.\n\n[![Build Status](https://ci.appveyor.com/api/projects/status/github/jonsequitur/Its.Validation?svg=true\u0026branch=master)](https://ci.appveyor.com/project/jonsequitur/its-validation)  [![NuGet Status](http://img.shields.io/nuget/v/Its.Validation.svg?style=flat)](https://www.nuget.org/packages/Its.Validation/)\n\nDefine a validation rule:\n\n```csharp\nvar wontGoBadTooSoon = Validate.That\u003cFruit\u003e(fruit =\u003e fruit.ExpirationDate \u003e DateTime.Now.AddDays(5));\nbool isValid = wontGoBadTooSoon.Check(lemon);\n```\n\nCompose it into other rules:\n\n```csharp\nvar basketWontGoBadTooSoon = \n  Validate.That\u003cFruitBasket\u003e(basket =\u003e\n    basket.Fruits.Every(wontGoBadTooSoon));\n```\n\nGet information from the rule for display:\n\n```csharp\nvar wontGoBadTooSoon = \n  Validate.That\u003cFruit\u003e(fruit =\u003e \n    fruit.ExpirationDate.As(\"expiration\") \u003e DateTime.Now.AddDays(5));\n```\n\nTransform and format the information for display:\n\n```csharp\nvar wontGoBadTooSoon = \n  Validate.That\u003cFruit\u003e(fruit =\u003e\n      fruit.As(\"fruitname\", f =\u003e f.Name).ExpirationDate.As(\"expiration\") \u003e DateTime.Now.AddDays(5.As(\"days_in_transit\")))\n    .WithMessage(\"A {fruitname} that expires on {expiration:D} won't last for {days_in_transit} days.\");\n\n// OR localized:\n\n    .WithMessage(Resources.BasketMustPreventScurvy);\n```\n\nCombine rules:\n\n```csharp\nvar plan = new ValidationPlan\u003cFruitBasket\u003e\n               {\n                    basketHasFruit,\n                    basketWontGoBadTooSoon\n               };\n```\n\nDefine rule dependencies:\n\n```csharp\nvar plan = new ValidationPlan\u003cFruitBasket\u003e\n               {\n                    basketHasFruit,               \n                    basketWontGoBadTooSoon.When(basketHasFruit)\n               };\n```\n\nTest your validation plan:\n\n```csharp\nvar basket = new FruitBasket();\n\nvar failures = plan.Execute(basket);\n\nfailures.Count(f =\u003e f.Message == \"Your basket must contain some fruit.\")\n        .Should()\n        .Be(1);\n```\n\nExtend the validation results with your own types:\n\n```csharp\nvar upcCodeExists = \n  Validation.That\u003cFruit\u003e(fruit =\u003e database.UpcCodes.Exists(upc =\u003e upc.Code == fruit.UpcCode))\n    .With\u003cDatabaseError\u003e(DatabaseErrors.UpcCodeDoesNotExist);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonsequitur%2Fits.validation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonsequitur%2Fits.validation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonsequitur%2Fits.validation/lists"}