using Extrudex.API.DTOs.Materials;
using FluentValidation;

namespace Extrudex.API.Validators;

/// <summary>
/// Validation rules for creating a MaterialBase.
/// </summary>
public class CreateMaterialBaseRequestValidator : AbstractValidator<CreateMaterialBaseRequest>
{
    public CreateMaterialBaseRequestValidator()
    {
        RuleFor(x => x.Name)
            .NotEmpty().WithMessage("Material name is required.")
            .MaximumLength(50).WithMessage("Material name must not exceed 50 characters.");

        RuleFor(x => x.DensityGperCm3)
            .GreaterThan(0).WithMessage("Density must be greater than zero.");
    }
}

/// <summary>
/// Validation rules for updating a MaterialBase.
/// </summary>
public class UpdateMaterialBaseRequestValidator : AbstractValidator<UpdateMaterialBaseRequest>
{
    public UpdateMaterialBaseRequestValidator()
    {
        RuleFor(x => x.Name)
            .NotEmpty().WithMessage("Material name is required.")
            .MaximumLength(50).WithMessage("Material name must not exceed 50 characters.");

        RuleFor(x => x.DensityGperCm3)
            .GreaterThan(0).WithMessage("Density must be greater than zero.");
    }
}

/// <summary>
/// Validation rules for creating a MaterialFinish.
/// </summary>
public class CreateMaterialFinishRequestValidator : AbstractValidator<CreateMaterialFinishRequest>
{
    public CreateMaterialFinishRequestValidator()
    {
        RuleFor(x => x.Name)
            .NotEmpty().WithMessage("Finish name is required.")
            .MaximumLength(50).WithMessage("Finish name must not exceed 50 characters.");

        RuleFor(x => x.MaterialBaseId)
            .NotEmpty().WithMessage("MaterialBaseId is required.");
    }
}

/// <summary>
/// Validation rules for updating a MaterialFinish.
/// </summary>
public class UpdateMaterialFinishRequestValidator : AbstractValidator<UpdateMaterialFinishRequest>
{
    public UpdateMaterialFinishRequestValidator()
    {
        RuleFor(x => x.Name)
            .NotEmpty().WithMessage("Finish name is required.")
            .MaximumLength(50).WithMessage("Finish name must not exceed 50 characters.");

        RuleFor(x => x.MaterialBaseId)
            .NotEmpty().WithMessage("MaterialBaseId is required.");
    }
}

/// <summary>
/// Validation rules for creating a MaterialModifier.
/// </summary>
public class CreateMaterialModifierRequestValidator : AbstractValidator<CreateMaterialModifierRequest>
{
    public CreateMaterialModifierRequestValidator()
    {
        RuleFor(x => x.Name)
            .NotEmpty().WithMessage("Modifier name is required.")
            .MaximumLength(50).WithMessage("Modifier name must not exceed 50 characters.");

        RuleFor(x => x.MaterialBaseId)
            .NotEmpty().WithMessage("MaterialBaseId is required.");
    }
}

/// <summary>
/// Validation rules for updating a MaterialModifier.
/// </summary>
public class UpdateMaterialModifierRequestValidator : AbstractValidator<UpdateMaterialModifierRequest>
{
    public UpdateMaterialModifierRequestValidator()
    {
        RuleFor(x => x.Name)
            .NotEmpty().WithMessage("Modifier name is required.")
            .MaximumLength(50).WithMessage("Modifier name must not exceed 50 characters.");

        RuleFor(x => x.MaterialBaseId)
            .NotEmpty().WithMessage("MaterialBaseId is required.");
    }
}