Path: redb/redb.Core/Providers/IValidationProvider.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Core/Providers/IValidationProvider.cs
----
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using redb.Core.Models.Contracts;
namespace redb.Core.Providers
{
///
/// Schema validation result.
///
public class SchemaValidationResult
{
public bool IsValid { get; set; }
public List Issues { get; set; } = new();
public SchemaChangeReport? ChangeReport { get; set; }
}
///
/// Validation issue.
///
public class ValidationIssue
{
public ValidationSeverity Severity { get; set; }
public string PropertyName { get; set; } = string.Empty;
public string Message { get; set; } = string.Empty;
public string? SuggestedFix { get; set; }
}
///
/// Validation issue severity level.
///
public enum ValidationSeverity
{
Info,
Warning,
Error
}
///
/// Schema change report.
///
public class SchemaChangeReport
{
public List Changes { get; set; } = new();
public bool HasBreakingChanges { get; set; }
}
///
/// Structure change.
///
public class StructureChange
{
public ChangeType Type { get; set; }
public string PropertyName { get; set; } = string.Empty;
public string? OldValue { get; set; }
public string? NewValue { get; set; }
public bool IsBreaking { get; set; }
}
///
/// Change type.
///
public enum ChangeType
{
Added,
Removed,
Modified,
TypeChanged,
NullabilityChanged,
ArrayChanged
}
///
/// Supported type information.
///
public class SupportedType
{
public string Name { get; set; } = string.Empty;
public string DbType { get; set; } = string.Empty;
public string DotNetType { get; set; } = string.Empty;
public long Id { get; set; }
public bool SupportsArrays { get; set; } = true;
public bool SupportsNullability { get; set; } = true;
public string? Description { get; set; }
}
///
/// Provider for schema and type validation.
///
public interface IValidationProvider
{
///
/// Get all supported types.
///
Task> GetSupportedTypesAsync(CancellationToken cancellationToken = default);
///
/// Validate C# type correspondence with REDB supported types.
///
Task ValidateTypeAsync(Type csharpType, string propertyName,
CancellationToken cancellationToken = default);
///
/// Validate schema before synchronization.
///
Task ValidateSchemaAsync(string schemeName, bool strictDeleteExtra = true,
CancellationToken cancellationToken = default) where TProps : class;
///
/// Validate schema before synchronization (with contract).
///
Task ValidateSchemaAsync(IRedbScheme scheme, bool strictDeleteExtra = true,
CancellationToken cancellationToken = default) where TProps : class;
///
/// Check schema change compatibility.
///
Task AnalyzeSchemaChangesAsync(IRedbScheme scheme,
CancellationToken cancellationToken = default) where TProps : class;
///
/// Validate property constraints and arrays.
///
ValidationIssue? ValidatePropertyConstraints(Type propertyType, string propertyName, bool isRequired, bool isArray);
}
}