Greeva.Domain.Validator
1.0.5
dotnet add package Greeva.Domain.Validator --version 1.0.5
NuGet\Install-Package Greeva.Domain.Validator -Version 1.0.5
<PackageReference Include="Greeva.Domain.Validator" Version="1.0.5" />
<PackageVersion Include="Greeva.Domain.Validator" Version="1.0.5" />
<PackageReference Include="Greeva.Domain.Validator" />
paket add Greeva.Domain.Validator --version 1.0.5
#r "nuget: Greeva.Domain.Validator, 1.0.5"
#:package Greeva.Domain.Validator@1.0.5
#addin nuget:?package=Greeva.Domain.Validator&version=1.0.5
#tool nuget:?package=Greeva.Domain.Validator&version=1.0.5
Greeva.Domain.Validator
FluentValidation-based domain model validators for Greeva electronic invoicing library.
Overview
Greeva.Domain.Validator provides comprehensive validation rules for all domain models in the Greeva electronic invoicing system using FluentValidation framework.
Key Features
- FluentValidation Integration: Modern, fluent validation rules
- SUNAT Compliance: Validation rules based on SUNAT requirements
- Comprehensive Coverage: Validators for all document types
- Custom Rules: Peruvian-specific validation logic (RUC, DNI, etc.)
- Cascading Validation: Automatic validation of nested objects
Validators Included
Document Validators
- InvoiceValidator: Invoice document validation
- NoteValidator: Credit/Debit note validation
- SummaryValidator: Daily summary validation
- VoidedValidator: Voided document validation
- DespatchValidator: Despatch guide validation
Entity Validators
- CompanyValidator: Company information validation
- ClientValidator: Customer information validation
- AddressValidator: Address validation with ubigeo
- DocumentValidator: Document reference validation
Detail Validators
- InvoiceDetailValidator: Invoice line item validation
- NoteDetailValidator: Note line item validation
- SummaryDetailValidator: Summary line validation
- DespatchDetailValidator: Despatch item validation
Usage
using FluentValidation;
using Greeva.Domain.Validator.Validators.v12;
using Greeva.Core.Domain.Sale;
// Validate an invoice
var invoice = new Invoice { /* ... */ };
var validator = new InvoiceValidator();
var result = validator.Validate(invoice);
if (!result.IsValid)
{
foreach (var error in result.Errors)
{
Console.WriteLine($"Error: {error.PropertyName} - {error.ErrorMessage}");
}
}
// Validate with specific rules
var validationResult = await validator.ValidateAsync(invoice,
options => options.IncludeRuleSets("BasicValidation"));
Validation Rules
Company Validation
- RUC format validation (11 digits)
- Required business name
- Valid address structure
- Legal representative information
Client Validation
- Document type validation (DNI, RUC, etc.)
- Document number format validation
- Required customer name
- Address validation when required
Invoice Validation
- Document series and number format
- Currency code validation
- Tax calculations verification
- Required fields validation
- Business rule compliance
Amount Validation
- Decimal precision validation
- Tax rate validation
- Total calculations verification
- Currency consistency
Custom Validation Rules
// RUC validation
RuleFor(x => x.Ruc)
.NotEmpty()
.WithMessage("RUC is required")
.Length(11)
.WithMessage("RUC must be 11 digits")
.Must(BeValidRuc)
.WithMessage("Invalid RUC format");
// DNI validation
RuleFor(x => x.NumDoc)
.Length(8)
.When(x => x.TipoDoc == "1")
.WithMessage("DNI must be 8 digits");
// Tax calculation validation
RuleFor(x => x)
.Must(HaveValidTaxCalculation)
.WithMessage("Tax calculation is incorrect");
Error Messages
All validation error messages are in Spanish to comply with SUNAT requirements:
- "El RUC es requerido"
- "La serie debe tener el formato correcto"
- "El cálculo de impuestos es incorrecto"
- "La fecha de emisión no puede ser futura"
Dependencies
- .NET 8.0
- FluentValidation 12.0.0
- Greeva.Core (domain models)
Related Packages
- Greeva.Core: Core domain models
- Greeva.Ubl.Validator: UBL XML schema validation
- Greeva.WebApi: Web API integration with validation
License
MIT License - see LICENSE file for details.
Support
For issues and questions, please visit: https://github.com/augustoteles/greeva/issues
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- FluentValidation (>= 12.0.0)
- Greeva.Core (>= 1.0.5)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Greeva.Domain.Validator:
| Package | Downloads |
|---|---|
|
Greeva.WebApi
Greeva library optimized for Web APIs with DI support and embedded templates |
GitHub repositories
This package is not used by any popular GitHub repositories.