Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 3 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,12 @@ jobs:
- os: ubuntu-latest
name-suffix: 'Linux'
test-filter: 'Category=SqlServer|Category!=SqlServer'
sqlserver: false
- os: macos-latest
name-suffix: 'macOS'
test-filter: 'Category=SqlServer|Category!=SqlServer'
sqlserver: false
test-filter: 'Category!=SqlServer'
- os: windows-2022
name-suffix: 'Windows'
test-filter: 'Category=SqlServer|Category!=SqlServer'
sqlserver: false

steps:
- uses: actions/checkout@v4
Expand All @@ -50,7 +47,7 @@ jobs:
echo "Generated SA password"

- name: Start SQL Server container
if: matrix.os == 'ubuntu-latest' && matrix.sqlserver == true
if: matrix.os == 'ubuntu-latest'
run: |
docker run -d \
--name sql-server \
Expand All @@ -73,7 +70,7 @@ jobs:
echo "SQL Server is ready!"

- name: Install SQL Server
if: matrix.os == 'windows-2022' && matrix.sqlserver == true
if: matrix.os == 'windows-2022'
uses: potatoqualitee/mssqlsuite@v1.11
with:
install: sqlengine, sqlclient
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,12 @@ jobs:
- os: ubuntu-latest
name-suffix: 'Linux'
test-filter: 'Category=SqlServer|Category!=SqlServer'
sqlserver: false
- os: macos-latest
name-suffix: 'macOS'
test-filter: 'Category=SqlServer|Category!=SqlServer'
sqlserver: false
test-filter: 'Category!=SqlServer'
- os: windows-2022
name-suffix: 'Windows'
test-filter: 'Category=SqlServer|Category!=SqlServer'
sqlserver: false

steps:
- uses: actions/checkout@v4
Expand All @@ -50,7 +47,7 @@ jobs:
echo "Generated SA password"

- name: Start SQL Server container
if: matrix.os == 'ubuntu-latest' && matrix.sqlserver == true
if: matrix.os == 'ubuntu-latest'
run: |
docker run -d \
--name sql-server \
Expand All @@ -73,7 +70,7 @@ jobs:
echo "SQL Server is ready!"

- name: Install SQL Server
if: matrix.os == 'windows-2022' && matrix.sqlserver == true
if: matrix.os == 'windows-2022'
uses: potatoqualitee/mssqlsuite@v1.11
with:
install: sqlengine, sqlclient
Expand Down
12 changes: 12 additions & 0 deletions PPWCode.Util.Validation.sln
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PPWCode.Util.Validation.IV.
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PPWCode.Util.Validation.IV.Tests", "src\IV.Tests\PPWCode.Util.Validation.IV.Tests.csproj", "{3BEF64F5-D4A7-4EE1-8693-9F1439598642}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PPWCode.Util.Validation.IV.NHibernate", "src\IV.NHibernate\PPWCode.Util.Validation.IV.NHibernate.csproj", "{38AD71C7-8C44-4CD7-8EA5-5793C76D4EA2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PPWCode.Util.Validation.IV.NHibernate.Tests", "src\IV.NHibernate.Tests\PPWCode.Util.Validation.IV.NHibernate.Tests.csproj", "{578BA57F-99E0-4865-A11E-1F0747997CA7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -57,6 +61,14 @@ Global
{3BEF64F5-D4A7-4EE1-8693-9F1439598642}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3BEF64F5-D4A7-4EE1-8693-9F1439598642}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3BEF64F5-D4A7-4EE1-8693-9F1439598642}.Release|Any CPU.Build.0 = Release|Any CPU
{38AD71C7-8C44-4CD7-8EA5-5793C76D4EA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{38AD71C7-8C44-4CD7-8EA5-5793C76D4EA2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{38AD71C7-8C44-4CD7-8EA5-5793C76D4EA2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{38AD71C7-8C44-4CD7-8EA5-5793C76D4EA2}.Release|Any CPU.Build.0 = Release|Any CPU
{578BA57F-99E0-4865-A11E-1F0747997CA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{578BA57F-99E0-4865-A11E-1F0747997CA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{578BA57F-99E0-4865-A11E-1F0747997CA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{578BA57F-99E0-4865-A11E-1F0747997CA7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# PPWCode.Util.Validation

This library is part of the .NET PPWCode project and (currently) contains specific types for the validation of country-specific identifiers. A separate library is included that adds support for these types in Entity Framework Core.
This library is part of the .NET PPWCode project and (currently) contains specific types for the validation of country-specific identifiers. Separate libraries are included that add support for these types in both Entity Framework Core and NHibernate.

For more information, see [PPWCode .NET Docs].


## PPWCode .NET

Development of the PPWCode .NET libraries is done in [GitHub] repositories, and
all releases (both stable and pre-release) are published on [NuGet].


## License and Copyright

Copyright 2014–2026 by [PeopleWare].
Expand Down
11 changes: 11 additions & 0 deletions docs/modules/ROOT/examples/project-nhibernate.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<!-- ... -->

<ItemGroup>
<!-- nuget package dependencies -->
<PackageReference Include="PPWCode.Util.Validation.IV" Version="1.2.0" />
<PackageReference Include="PPWCode.Util.Validation.IV.NHibernate" Version="1.2.0" />
</ItemGroup>

<!-- ... -->
</Project>
12 changes: 10 additions & 2 deletions docs/modules/ROOT/pages/changelog.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,26 @@ the link to the GitHub tag is only added once we are ready to release.
:github: https://github.com/peopleware/net-ppwcode-util-validation/releases/tag/IV%2F
:nuget-main: https://www.nuget.org/packages/PPWCode.Util.Validation.IV/
:nuget-efc: https://www.nuget.org/packages/PPWCode.Util.Validation.IV.EntityFrameworkCore/
:nuget-nhibernate: https://www.nuget.org/packages/PPWCode.Util.Validation.IV.NHibernate/
:ppwcode-docs: https://peopleware.github.io/net-ppwcode-docs/ppwcode-util-validation-iv/
:main: PPWCode.Util.Validation.IV
:efc: PPWCode.Util.Validation.IV.EntityFrameworkCore
:nhibernate: PPWCode.Util.Validation.IV.NHibernate


:release: 1.1.0
:release: 1.2.0
== `{release}`
include::partial$changelog-release-section.adoc[]
include::partial$changelog-{release}.adoc[]


:release: 1.1.0
== `{release}`
include::partial$changelog-old-release-section.adoc[]
include::partial$changelog-{release}.adoc[]


:release: 1.0.0
== `{release}`
include::partial$changelog-release-section.adoc[]
include::partial$changelog-old-release-section.adoc[]
include::partial$changelog-{release}.adoc[]
16 changes: 15 additions & 1 deletion docs/modules/ROOT/pages/getting-started.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
// helper attributes for package links
:nuget-main: https://www.nuget.org/packages/PPWCode.Util.Validation.IV/
:nuget-efc: https://www.nuget.org/packages/PPWCode.Util.Validation.IV.EntityFrameworkCore/
:nuget-nhibernate: https://www.nuget.org/packages/PPWCode.Util.Validation.IV.NHibernate/
:main: PPWCode.Util.Validation.IV
:efc: PPWCode.Util.Validation.IV.EntityFrameworkCore
:nhibernate: PPWCode.Util.Validation.IV.NHibernate

== Add NuGet package

Expand All @@ -14,11 +16,23 @@ The following packages are available:

- {nuget-main}[{main}], base library
- {nuget-efc}[{efc}], Entity Framework Core support
- {nuget-nhibernate}[{nhibernate}], NHibernate support


You can use your IDE to add the required libraries as dependencies to your project, or manually add them in the `.csproj` file. This would look similar to the following:


=== Entity Framework Core

[source,xml]
----
include::example$project-efc.csproj[]
----


=== NHibernate

[source,xml]
----
include::example$project.csproj[]
include::example$project-nhibernate.csproj[]
----
12 changes: 12 additions & 0 deletions docs/modules/ROOT/partials/changelog-1.2.0.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
////
The changelog for a specific release.
Note that it is best to update the changelog as new code is developed.

All attributes used, must be included in this file to keep it self-contained.

This file is translated into markdown and used for the release notes in the GitHub release!
////

=== New
* Support for NHibernate added
** See package `PPWCode.Util.Validation.IV.NHibernate`
13 changes: 13 additions & 0 deletions docs/modules/ROOT/partials/changelog-old-release-section.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
////
Note: double empty lines at the end of the file is done on purpose!
////

=== Release

* link:{github}{release}[GitHub]
* NuGet
** link:{nuget-main}{release}[{main}]
** link:{nuget-efc}{release}[{efc}]


// do not remove the preceding empty lines!
1 change: 1 addition & 0 deletions docs/modules/ROOT/partials/changelog-release-section.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Note: double empty lines at the end of the file is done on purpose!
* NuGet
** link:{nuget-main}{release}[{main}]
** link:{nuget-efc}{release}[{efc}]
** link:{nuget-nhibernate}{release}[{nhibernate}]


// do not remove the preceding empty lines!
4 changes: 4 additions & 0 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
<!-- PPWCode -->
<PackageVersion Include="PPWCode.Vernacular.Contracts.I" Version="1.*" />

<!-- ppwcode -->
<PackageVersion Include="PPWCode.Vernacular.NHibernate.IV" Version="1.0-*" />
<PackageVersion Include="PPWCode.Vernacular.NHibernate.IV.Test" Version="1.0-*" />

<!-- nunit -->
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.*" />
<PackageVersion Include="NUnit" Version="4.*" />
Expand Down
27 changes: 27 additions & 0 deletions src/IV.NHibernate.Tests/BaseQueryTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2026 by PeopleWare n.v..
// 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.

using PPWCode.Vernacular.NHibernate.IV;
using PPWCode.Vernacular.NHibernate.IV.Test;

namespace PPWCode.Util.Validation.IV.NHibernate.Tests;

public abstract class BaseQueryTests : BaseRepositoryFixture<int, TestIntAuditLog>
{
protected override string CatalogName
=> $"Test.{GetType().Assembly.GetName().Name}";

protected override IPpwHbmMapping PpwHbmMapping
=> new TestsSimpleModelMapper(new TestsMappingAssemblies());

protected override string IdentityName
=> "Test - IdentityName";
}
37 changes: 37 additions & 0 deletions src/IV.NHibernate.Tests/BaseRepositoryTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2026 by PeopleWare n.v..
// 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.

using PPWCode.Vernacular.Persistence.V;

namespace PPWCode.Util.Validation.IV.NHibernate.Tests;

public abstract class BaseRepositoryTests<T> : BaseQueryTests
where T : class, IIdentity<int>
{
protected abstract Func<Vernacular.NHibernate.IV.IRepository<T, int>> RepositoryFactory { get; }

protected Vernacular.NHibernate.IV.IRepository<T, int>? Repository { get; private set; }

protected override void OnSetup()
{
base.OnSetup();

Repository = RepositoryFactory();
SessionFactory.Statistics.Clear();
}

protected override void OnTeardown()
{
Repository = null;

base.OnTeardown();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Copyright 2026 by PeopleWare n.v..
// 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.

using System.Diagnostics.CodeAnalysis;

using NUnit.Framework;

using PPWCode.Util.Validation.IV.European.Belgium;
using PPWCode.Util.Validation.IV.NHibernate.Tests.Models;
using PPWCode.Util.Validation.IV.NHibernate.Tests.Repositories;
using PPWCode.Vernacular.Contracts.I;
using PPWCode.Vernacular.NHibernate.IV;

namespace PPWCode.Util.Validation.IV.NHibernate.Tests.IntegrationTests;

[SuppressMessage("ReSharper", "InconsistentNaming", Justification = "Tests")]
public class BelgianIdentificationsTests : BaseRepositoryTests<BelgianIdentifications>
{
protected override Func<IRepository<BelgianIdentifications, int>> RepositoryFactory
=> () => new BelgianIdentificationsRepository(SessionProvider);

[Test]
public void can_handle_belgian_identifications()
{
Contract.Requires(Repository != null);

// Arrange
BelgianIdentifications subject =
new BelgianIdentifications
{
BBAN = new BBAN("850-895676-978"),
DMFA = new DMFA("DMFAP123456789A"),
INSS = new INSS("55.25.02.008-01"),
KBO = new KBO("0453.834.195"),
RSZ = new RSZ("0133-296 720"),
IBAN = new IBAN("AL472 1211 0090 0000 0023 5698 741"),
BIC = new BIC("KREDBEBB"),
TemporaryRSZ = new TemporaryRSZ("5 105009119"),
VAT = new VAT("0453.834.195"),
CompanyLocalUnitNumber = new CompanyLocalUnitNumber("2.069.315153")
};

// Act
RunInsideTransaction(
() =>
{
Repository.SaveOrUpdate(subject);
Assert.That(subject.IdIsTransient, Is.False);
},
true);

BelgianIdentifications? actual = Repository.GetById(subject.Id);

// Assert
Assert.That(BelgianIdentifications.Comparer.Equals(subject, actual), Is.True);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright 2026 by PeopleWare n.v..
// 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.

using NHibernate.Mapping.ByCode;

using NUnit.Framework;

using PPWCode.Vernacular.NHibernate.IV;

namespace PPWCode.Util.Validation.IV.NHibernate.Tests.IntegrationTests.Mapping;

[TestFixture]
public class ConventionMappingTests
{
[Test]
[Explicit]
public void XmlMapping()
{
IPpwHbmMapping mapper = new TestsSimpleModelMapper(new TestsMappingAssemblies());
Console.WriteLine(mapper.HbmMapping.AsString());
}
}
Loading
Loading