Skip to content

Commit

Permalink
Db code gen port + CDC + other fixes/improvements (#96)
Browse files Browse the repository at this point in the history
* Create the new typed config and serialize XML to YAML.

* Configure test table and generate existing baseline.

* Part way through Get port.

* Fix post merge.

* Get stored procedure ported.

* Simpligy Get handlebars template for greater reuse in another templates.

* GetColl port complete.

* Correct merge.

* Fix execution errors.

* Create stored procedure ported.

* Update stored procedure port.

* Generate Upsert using legacy code-gen.

* Upsert stored procedure ported.

* Changed up the SettableColumns logic.

* Delete stored procedure port.

* Merge stored procedure ported.

* Ensure special columns are always included. Additional tidy-ups.

* Udt port.

* Ported TVP.

* Ported EfModel.

* Pre View port.

* Port DB View code-egn. Add capability to specify the schema application order. Run all tests.

* Ported remaining database.core templates to handlebars.

* Decommission existing code-gen; we are now all in with handlebars.

* Code cleanup. Schema re-generation.

* Implemented XML to YAML conversion.

* Fix schema issue.

* Re-gen My.Hr. End-to-end test. Publish pre-release nuget packages.

* Property.IsEntity defaults to true where Type is ChangeLog. Update documentation accordingly. Rejig the converted YAML format.

* Documentation updates.

* Further doco updates. Improve CollectionRule for UniqueKey checking.

* Documentation updates.

* Build out core Query capability.

* Build out CDC outbox POC.

* Replace tabs with spaces for CDC.

* CDC-gen tabs to spaces

* Updated documentation comments.

* Enable a supported concept to database tooling to minimize incorrect option selection, etc.

* Added additional column filtering on stored procedures.

* Add YAML support for Database tooling.

* Added the XML to YAML support for database.

* Further CDC oriented updates.

* Merge in master.

* Agent DI simplification.

* Documentation updates.

* Re-gen.

* Added validation of yaml configuration.
Visual Studio 16.8.2 update compiler related fixes.

* Entity documentation re-gen; including YAML/JSON + XML variants

* Re-implemented code-gen config validation approach.

* Override stored procedure name.
Query config overrides inferred db metadata.

* Integrate the Database markdown generation.

* Updated examples, re-gen markdown.
Re-gen schemas.

* Updated Database project changelog.

* Start process of CDC code-gen and related config

* Continued CDC refactored approach.

* Complete refactor entities; start the CDC data refactoring.

* Parital Cdc update.

* CDC execute batch.

* Created new Beef.Data.Database.Cdc project.

* Add tracking to ensure same data not sent more than once.

* Renamed CdcExecutor to CdcDataOrchestrator. Added Service Collection gen. Started Contact/Address test.

* Added test with OneToOne. Resolved issues with multiple background services running concurrently.

* Generated the schema and documentation.

* Updating documentation.

* Added missing documentation for ServiceCollection.

* Improve robustness of the ExecuteEnvelope stored proc; plus correct issue where including LSN from last envelope.

* Make the code-generated artefact path and .NET namespace configurable.

* Deprecate table view generation; must now use the new Query config.
Fix redundant variable in cdc execute envelope stored procedure.

* Added support for non-cdc joins.
Added new LoggerEventPublisher.
Updated cdc log messages.

* Add Inherit support to CodeGen Script.xml files.
Upgrade Handlebars NuGet and correct issues.

* Update documentation and schemas.
Rename the proto naming convention to support configurable Namespace.
Update Beef.Template to latest version numbers, plus rename of CodeGen XML files.

* Enable overridding of Script name in Console app.
Add `IConfigEditor` to enable runtime customization opportunity.
Test and adjust to allow customized Script and/or Template.
Update related doco.

* Fix broken links.

* Re-gen codegen documentation and schemas.

* Report unknown attributes during translation.

* Move the `Generated` folder specification to be specifically defined, versus happening magically in the background. Enables overriding of behaviour where required.
Further doco updates.
Add --environmentVariableName option.

* Alter approach for ScriptNew to be more flexible.
Implement means to create migrations script for a cdc envelope.

* Remove the previously added Hack to output CDC Table Create when using DbUp - the anti-pattern.
Split out DbUp and DacPac to have different approaches; via alternate codegen Scripts files.

* Reg-gen schemas and doco.

* Validation ValidateAsync and RunAync changes.

* Start introducing DI.

* Update templates to support DI.

* Integrate Validation DI.

* Finish out the Validation testing.
Update the samples.

* Re-gen doco and schema.

* Get all tests to pass.
Close out doco/schemas re-gen.
Update changelogs.

* Mass DebuggerStepThrough addition.

* Enhance the EventSubscriberTester

* Update My.Hr solution/doco.
Improve config for schema.

* Fixed up some additional doco.

* Add Identifier Generator.

* Rename the CDC Envelope to Outbox.

* Added unique EventData.EventId.

* Add support for EventData.SetValue.

* Added EventTransaction support.

* Enable CDC for entities with special IsDeleted and RowVersion/ETag colums.

* Correct the ETag generation to use MD5 Hash versus HashCode.

* Provide better support for "ETag" code-gen.

* Review/validate the validation caching for performance.

* Addtional doco updates.

* PragmaWarnings implemantation. Apply to Demo.

* Re-gen all code-gen.

* Clean up redundant pragma warnings in beef code base

* Pragma warning disable.

* WebApiOperationType to ManagerOperationType and code-gen update.

* Fix some CDC challenges from additional testing.

* Event Send.

* IUniqueKey explicit implementation requirement.
Published vs Sent Event testing.

* Tidy up. Last changes.
  • Loading branch information
chullybun authored Feb 3, 2021
1 parent 54ea010 commit 4294cb7
Show file tree
Hide file tree
Showing 839 changed files with 27,094 additions and 12,851 deletions.
14 changes: 14 additions & 0 deletions Beef.sln
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{2429F084-A
samples\My.Hr\docs\Performance-Review.md = samples\My.Hr\docs\Performance-Review.md
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Beef.Demo.Cdc", "samples\Demo\Beef.Demo.Cdc\Beef.Demo.Cdc.csproj", "{0915D101-40D4-434F-9539-12F509137220}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Beef.Data.Database.Cdc", "src\Beef.Data.Database.Cdc\Beef.Data.Database.Cdc.csproj", "{6B3BD95B-E789-4EBA-B295-99E7A48B9120}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -300,6 +304,14 @@ Global
{54B168EB-C74D-4588-9D9E-BDD386D84C1F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{54B168EB-C74D-4588-9D9E-BDD386D84C1F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{54B168EB-C74D-4588-9D9E-BDD386D84C1F}.Release|Any CPU.Build.0 = Release|Any CPU
{0915D101-40D4-434F-9539-12F509137220}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0915D101-40D4-434F-9539-12F509137220}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0915D101-40D4-434F-9539-12F509137220}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0915D101-40D4-434F-9539-12F509137220}.Release|Any CPU.Build.0 = Release|Any CPU
{6B3BD95B-E789-4EBA-B295-99E7A48B9120}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6B3BD95B-E789-4EBA-B295-99E7A48B9120}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6B3BD95B-E789-4EBA-B295-99E7A48B9120}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6B3BD95B-E789-4EBA-B295-99E7A48B9120}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -358,6 +370,8 @@ Global
{F962F1CC-DA7C-4146-8D36-0E6C74C261E5} = {FEA11C67-E7C7-49BC-99F5-5E5BF8F8674F}
{54B168EB-C74D-4588-9D9E-BDD386D84C1F} = {00C76124-DB2C-4653-B8C1-F7260784EA5A}
{2429F084-A3F8-4F8A-88FF-E3BF5B210C13} = {FEA11C67-E7C7-49BC-99F5-5E5BF8F8674F}
{0915D101-40D4-434F-9539-12F509137220} = {FDB20FC0-9D38-4E22-87EF-2865877B0F84}
{6B3BD95B-E789-4EBA-B295-99E7A48B9120} = {7A307618-3ADF-49DF-A490-A37D4404158D}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {42D71086-61E6-4D31-B4B8-BFC8CC471428}
Expand Down
48 changes: 27 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ Each of the key layers / components above are further detailed (`Xxx` denotes th

### Event-driven

To support the goals of an [Event-driven Architecture](https://en.wikipedia.org/wiki/Event-driven_architecture) _Beef_ enables the key capabilities; the publishing and subscribing of events (messages) to and from an event-stream (or equivalent).
To support the goals of an [Event-driven Architecture](https://en.wikipedia.org/wiki/Event-driven_architecture) _Beef_ enables the key capabilities; the publishing (Producer) and subscribing (Consumer) of events (messages) to and from an event-stream (or equivalent).

![Layers](./docs/images/EventDrivenArchitecture.png "Event-Driven Architecture")

- **Publish** - the publishing of events is integrated into the API processing pipeline; this is enabled within the [Service orchestration](./docs/Layer-DataSvc.md) layer to ensure consistency of approach. _Beef_ is largely agnostic to the underlying event/messaging infrastructure (event-stream) and must be implemented by the developer.
- **Producer / Publisher** - the publishing of events is integrated into the API processing pipeline; this is enabled within the [Service orchestration](./docs/Layer-DataSvc.md) layer to ensure consistency of approach. _Beef_ is largely agnostic to the underlying event/messaging infrastructure (event-stream) and must be implemented by the developer.

- **Subscribe** - a event subscriber is then implemented to listen to events from the underlying event/messaging infrastructure (event-stream) and perform the related action. The event subscriber is encouraged to re-use the underlying logic by hosting the _Beef_ capabilities to implement. The [Domain logic](./docs/Layer-Manager.md) layer can be re-leveraged to perform the underlying business logic on the receipt of an event (within the context of a subscribing domain).
- **Consumer / Subscriber** - a event subscriber is then implemented to listen to events from the underlying event/messaging infrastructure (event-stream) and perform the related action. The event subscriber is encouraged to re-use the underlying logic by hosting the _Beef_ capabilities to implement. The [Domain logic](./docs/Layer-Manager.md) layer can be re-leveraged to perform the underlying business logic on the receipt of an event (within the context of a subscribing domain).

The _Beef_ support for an event-driven architecture is enabled by the [`Beef.Events`](./src/Beef.Events) assembly.

Expand All @@ -131,13 +131,14 @@ A key accelerator for _Beef_ is achieved using a flexible [code generation](./to

An extensive framework of capabilities has also been developed to support this entity-based development. Specifically around entities and their collections, entity mapping, reference data, validation, standardised exceptions, standardised messaging, basic caching, logging, flat-file reader/writer, RESTful API support, ADO.NET database access, Entity Framework (EF) data access, OData access, Azure Service Bus, long running (execution and triggers) processes, etc.

The **key** capabilities for _Beef_ are enabled by the following run-time assemblies:
The **key** capabilities for _Beef_ are enabled by the following runtime assemblies:

Assembly | Description | NuGet | Changes
-|-|-|-
[`Beef.Core`](./src/Beef.Core) | Core foundational framework. | [![NuGet version](https://badge.fury.io/nu/Beef.core.svg)](https://badge.fury.io/nu/Beef.core) | [Log](./src/Beef.Core/CHANGELOG.md)
[`Beef.AspNetCore.WebApi`](./src/Beef.AspNetCore.WebApi) | ASP.NET Core Web API framework. | [![NuGet version](https://badge.fury.io/nu/Beef.AspNetCore.WebApi.svg)](https://badge.fury.io/nu/Beef.AspNetCore.WebApi) | [Log](./src/Beef.AspNetCore.WebApi/CHANGELOG.md)
[`Beef.AspNetCore.WebApi`](./src/Beef.AspNetCore.WebApi) | ASP.NET Core Web API framework. | [![NuGet version](https://badge.fury.io/nu/Beef.AspNetCore.WebApi.svg)](https://badge.fury.io/nu/Beef.AspNetCore.WebApi) | [Log](./src/Beef.AspNetCore.WebApi/ChangeLog.md)
[`Beef.Data.Database`](./src/Beef.Data.Database) | ADO.NET database framework. | [![NuGet version](https://badge.fury.io/nu/Beef.Data.Database.svg)](https://badge.fury.io/nu/Beef.Data.Database) | [Log](./src/Beef.Data.Database/CHANGELOG.md)
[`Beef.Data.Database.Cdc`](./src/Beef.Data.Database.Cdc) | ADO.NET database Change Data Capture (CDC) framework. | [![NuGet version](https://badge.fury.io/nu/Beef.Data.Database.Cdc.svg)](https://badge.fury.io/nu/Beef.Data.Database.Cdc) | [Log](./src/Beef.Data.Database.Cdc/CHANGELOG.md)
[`Beef.Data.EntityFrameworkCore`](./src/Beef.Data.EntityFrameworkCore) | Entity Framework (EF) Core framework. | [![NuGet version](https://badge.fury.io/nu/Beef.Data.EntityFrameworkCore.svg)](https://badge.fury.io/nu/Beef.Data.EntityFrameworkCore) | [Log](./src/Beef.Data.EntityFrameworkCore/CHANGELOG.md)
[`Beef.Data.Cosmos`](./src/Beef.Data.Cosmos) | Cosmos DB execution framework. | [![NuGet version](https://badge.fury.io/nu/Beef.Data.Cosmos.svg)](https://badge.fury.io/nu/Beef.Data.Cosmos) | [Log](./src/Beef.Data.Cosmos/CHANGELOG.md)
[`Beef.Data.OData`](./src/Beef.Data.OData) | OData execution framework. | [![NuGet version](https://badge.fury.io/nu/Beef.Data.OData.svg)](https://badge.fury.io/nu/Beef.Data.OData) | [Log](./src/Beef.Data.OData/CHANGELOG.md)
Expand Down Expand Up @@ -186,22 +187,27 @@ The following are references to additional documentation (these are all accessib
### Code-generation

- [Code generation](./tools/Beef.CodeGen.Core/README.md)
- [Template structure](./docs/Template-structure.md)
- Entity-driven:
- [CodeGeneration element](./docs/Entity-CodeGeneration-element.md)
- [Entity element](./docs/Entity-Entity-element.md)
- [Property element](./docs/Entity-Property-element.md)
- [Operation element](./docs/Entity-Operation-element.md)
- [Parameter element](./docs/Entity-Parameter-element.md)
- [Const element](./docs/Entity-Const-element.md)
- Table-driven ([database](./tools/Beef.Database.Core/README.md)):
- [CodeGeneration element](./docs/Table-CodeGeneration-element.md)
- [Table element](./docs/Table-Table-element.md)
- [Stored procedure element](./docs/Table-StoredProcedure-element.md)
- [Parameter element](./docs/Table-Parameter-element.md)
- [Where element](./docs/Table-Where-element.md)
- [OrderBy element](./docs/Table-OrderBy-element.md)
- [Execute element](./docs/Table-Execute-element.md)
- **Entity-driven** (.NET C#) - CodeGeneration - [YAML/JSON](./docs/Entity-CodeGeneration-Config.md) or [XML](./docs/Entity-CodeGeneration-Config-Xml.md)
- Entity - [YAML/JSON](./docs/Entity-Entity-Config.md) or [XML](./docs/Entity-Entity-Config-Xml.md)
- Properties - [YAML/JSON](./docs/Entity-Property-Config.md) or [XML](./docs/Entity-Property-Config-Xml.md)
- Constants - [YAML/JSON](./docs/Entity-Const-Config.md) or [XML](./docs/Entity-Const-Config-Xml.md)
- Operations - [YAML/JSON](./docs/Entity-Operation-Config.md) or [XML](./docs/Entity-Operation-Config-Xml.md)
- Parameters - [YAML/JSON](./docs/Entity-Parameter-Config.md) or [XML](./docs/Entity-Parameter-Config-Xml.md)
- **Database-driven** ([database](./tools/Beef.Database.Core/README.md)) - CodeGeneration - [YAML/JSON](./docs/Database-CodeGeneration-Config.md) or [XML](./docs/Database-CodeGeneration-Config-Xml.md)
- Query - [YAML/JSON](./docs/Database-Query-Config.md) or [XML](./docs/Database-Query-Config-Xml.md)
- QueryJoin - [YAML/JSON](./docs/Database-QueryJoin-Config.md) or [XML](./docs/Database-QueryJoin-Config-Xml.md)
- QueryJoinOn - [YAML/JSON](./docs/Database-QueryJoinOn-Config.md) or [XML](./docs/Database-QueryJoinOn-Config-Xml.md)
- QueryWhere - [YAML/JSON](./docs/Database-QueryWhere-Config.md) or [XML](./docs/Database-QueryWhere-Config-Xml.md)
- QueryOrder - [YAML/JSON](./docs/Database-QueryOrder-Config.md) or [XML](./docs/Database-QueryOrder-Config-Xml.md)
- Table - [YAML/JSON](./docs/Database-Table-Config.md) or [XML](./docs/Database-Table-Config-Xml.md)
- StoredProcedure - [YAML/JSON](./docs/Database-StoredProcedure-Config.md) or [XML](./docs/Database-StoredProcedure-Config-Xml.md)
- Parameter - [YAML/JSON](./docs/Database-Parameter-Config.md) or [XML](./docs/Database-Parameter-Config-Xml.md)
- Where - [YAML/JSON](./docs/Database-Where-Config.md) or [XML](./docs/Database-Where-Config-Xml.md)
- OrderBy - [YAML/JSON](./docs/Database-OrderBy-Config.md) or [XML](./docs/Database-OrderBy-Config-Xml.md)
- Execute - [YAML/JSON](./docs/Database-Execute-Config.md) or [XML](./docs/Database-Execute-Config-Xml.md)
- Cdc - [YAML/JSON](./docs/Database-Cdc-Config.md) or [XML](./docs/Database-Cdc-Config-Xml.md)
- CdcJoin - [YAML/JSON](./docs/Database-CdcJoin-Config.md) or [XML](./docs/Database-CdcJoin-Config-Xml.md)
- CdcJoinOn - [YAML/JSON](./docs/Database-CdcJoinOn-Config.md) or [XML](./docs/Database-CdcJoinOn-Config-Xml.md)

### Major/significant versions

Expand Down
49 changes: 26 additions & 23 deletions docs/Beef-Validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,25 +151,27 @@ Each property for the entity is configured using the `Property` method and a cor
An example is as follows:

``` csharp
public class PersonValidator : Validator<Person, PersonValidator>
public class PersonValidator : Validator<Person>
{
public PersonValidator()
{
Property(x => x.Name).Mandatory().String(maxLength: 50);
Property(x => x.Birthday).CompareValue(CompareOperator.LessThanEqual, DateTime.Now, "today");
}

protected override void OnValidate(ValidationContext<Test> context)
protected override Task OnValidateAsync(ValidationContext<Test> context)
{
// Check that Amount property has not had an error already; then validate and error.
context.Check(x = x.Amount, (val) => val <= 100, "{0} must be greater than 100.");

return Task.CompletedTask;
}
}

var person = new Person { Name = "Freddie", Birthday = new DateTime(1946, 09, 05), Amount = 150 };

// Use the static default property to access the validator.
PersonValidator.Default.Validate(person).ThrowOnError();
// Validate the value.
var result = await new PersonValidator().ValidateAsync(person);
```

<br/>
Expand All @@ -184,10 +186,10 @@ An example is as follows:
var person = new Person { Name = "Freddie", Birthday = new DateTime(1946, 09, 05);

// Create an entity-based validator on the fly.
Validator<Test>.Create()
var result = await Validator<Test>.Create()
.HasProperty(x => x.Name, p => p.Mandatory().String(maxLength: 50))
.HasProperty(x => x.Birthdar, p => p.CompareValue(CompareOperator.LessThanEqual, DateTime.Now, "today"))
.Validate(person).ThrowOnError();
.ValidateAsync(person);
```

<br/>
Expand All @@ -200,10 +202,11 @@ Values, both entity and non-entity, can be validated directly. Examples are as f
var person = new Person { Name = "Freddie", Birthday = new DateTime(1946, 09, 05);

// Validate an entity value; being the Person class.
person.Validate().Entity(TestValidator.Default).Run();
var pv = new PersonValidator();
await person.Validate().Entity(pv).RunAsync();

// Validate a value (e.g. a string, int, DateTime, etc.) without an entity-based validator.
person.Name.Validate().Mandatory().String(maxLength: 10).Run(throwOnError: true);
await person.Name.Validate().Mandatory().String(maxLength: 10).RunAsync(throwOnError: true);
```

<br/>
Expand Down Expand Up @@ -235,9 +238,9 @@ To support reusablility of property validations a `CommonValidator` is used to e
An example is as follows:

``` csharp
var cv = CommonValidator<string> _cv = CommonValidator<string>.Create(v => v.String(5).Must(x => x.Value != "XXXXX"));
var cv = CommonValidator<string> _cv = CommonValidator.Create<string>(v => v.String(5).Must(x => x.Value != "XXXXX"));

var v = Validator<TestData>.Create()
var v = Validator.Create<TestData>()
.HasProperty(x => x.Text, p => p.Mandatory().Common(cv));
```

Expand Down Expand Up @@ -277,18 +280,18 @@ Property(x => x.PhoneNo).String(new Regex(@"\+0\d{9}|\+0[1-9]\d{12}|0[1-9]\d{8}|
Property(x => x.Gender).Mandatory().IsValid();

// Check the sub entity exists (mandatory) and is valid (using defined validator).
Property(x => x.SubTest).Mandatory().Entity(Test2Validator.Default);
Property(x => x.SubTest).Mandatory().Entity().With(test2Validator);

// Check the sub entity collection (exists), has 1-4 items in the collection, and each is valid (using defined validator).
Property(x => x.SubTesters).Mandatory().Collection(minCount: 1, maxCount: 4, item: new CollectionRuleItem<Test2>(Test2Validator.Default));
Property(x => x.SubTesters).Mandatory().Collection(minCount: 1, maxCount: 4, item: CollectionRuleItem.Create<Test2>(test2Validator));
```

The following demonstrates the mixing of both entity-based options:

``` csharp
public class PersonValidator : Validator<Person, PersonValidator>
public class PersonValidator : Validator<Person>
{
private static readonly Validator<Address> _addressValidator = Validator<Address>.Create()
private static readonly Validator<Address> _addressValidator = Validator.Create<Address>()
.HasProperty(x => x.Street, p => p.Mandatory().String(50))
.HasProperty(x => x.City, p => p.Mandatory().String(50));

Expand All @@ -301,7 +304,7 @@ public class PersonValidator : Validator<Person, PersonValidator>
Property(x => x.LastName).Mandatory().String(50);
Property(x => x.Gender).Mandatory().IsValid();
Property(x => x.Birthday).Mandatory().CompareValue(CompareOperator.LessThanEqual, DateTime.Now, "Today");
Property(x => x.Address).Entity(_addressValidator);
Property(x => x.Address).Entity().With(_addressValidator);
}
}
```
Expand All @@ -321,7 +324,7 @@ The `RuleSet` represents a conditional validation rule for an entity, in that it
The following demonstrates `RuleSet` usage for an *Entity-based validator class*:

``` csharp
public class TestItemValidator : Validator<TestItem, TestItemValidator>
public class TestItemValidator : Validator<TestItem>
{
public TestItemValidator()
{
Expand All @@ -341,7 +344,7 @@ public class TestItemValidator : Validator<TestItem, TestItemValidator>
The following demonstrates `HasRuleSet` usage for an `Entity-based inline validator`:

``` csharp
var v = Validator<TestItem>.Create()
var v = Validator.Create<TestItem>()
.HasRuleSet(x => x.Value.Code == "A", y =>
{
y.Property(x => x.Text).Mandatory().Must(x => x.Text == "A");
Expand All @@ -361,8 +364,8 @@ Where entities leverage inheritence, having the corresponding validators include
The following is an example of using the `IncludeBase` method:

``` csharp
var r = Validator<TestData>.Create()
.IncludeBase(TestDataBaseValidator.Default)
var r = Validator.Create<TestData>()
.IncludeBase(testDataBaseValidator)
.HasProperty(x => x.CountB, p => p.Mandatory().CompareValue(CompareOperator.GreaterThan, 10))
.Validate(new TestData { CountB = 0 });
```
Expand All @@ -376,8 +379,8 @@ The `MultiValidator` enables the validation of multiple values there is a need t
An example is as follows:

``` csharp
MultiValidator.Create()
.Add(person.Validate(nameof(value)).Mandatory().Entity(PersonValidator.Default))
.Add(other.Validate(nameof(other)).Mandatory().Entity(OtherValidator.Default))
.Run().ThrowOnError();
var result = await MultiValidator.Create()
.Add(person.Validate(nameof(value)).Mandatory().Entity(personValidator))
.Add(other.Validate(nameof(other)).Mandatory().Entity(otherValidator))
.RunAsync();
```
Loading

0 comments on commit 4294cb7

Please sign in to comment.