Path: redb/redb.Core/Models/Users/UserValidationResult.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/Models/Users/UserValidationResult.cs
----
using System.Collections.Generic;
namespace redb.Core.Models.Users
{
///
/// User data validation result
///
public class UserValidationResult
{
///
/// Validation passed successfully
///
public bool IsValid { get; set; }
///
/// List of validation errors
///
public List Errors { get; set; } = new();
///
/// Add validation error
///
public void AddError(string field, string message)
{
Errors.Add(new ValidationError { Field = field, Message = message });
IsValid = false;
}
///
/// Add validation error
///
public void AddError(ValidationError error)
{
Errors.Add(error);
IsValid = false;
}
///
/// Create successful validation result
///
public static UserValidationResult Success()
{
return new UserValidationResult { IsValid = true };
}
///
/// Create validation result with error
///
public static UserValidationResult WithError(string field, string message)
{
var result = new UserValidationResult();
result.AddError(field, message);
return result;
}
}
///
/// Validation error
///
public class ValidationError
{
///
/// Field with error
///
public string Field { get; set; } = "";
///
/// Error message
///
public string Message { get; set; } = "";
///
/// Error code (optional)
///
public string? ErrorCode { get; set; }
}
}