// EN: Validators for User commands (update, delete).
// VI: Validators cho cac commands User (cap nhat, xoa).

using FluentValidation;
using IamService.API.Application.Commands.Users;

namespace IamService.API.Application.Validations;

/// <summary>
/// EN: Validator for UpdateUserCommand.
/// VI: Validator cho UpdateUserCommand.
/// </summary>
public class UpdateUserCommandValidator : AbstractValidator<UpdateUserCommand>
{
    public UpdateUserCommandValidator()
    {
        RuleFor(x => x.UserId)
            .NotEmpty()
            .WithMessage("User ID is required / User ID la bat buoc");

        RuleFor(x => x.FirstName)
            .MaximumLength(100)
            .WithMessage("First name must not exceed 100 characters / Ho khong vuot qua 100 ky tu")
            .When(x => x.FirstName != null);

        RuleFor(x => x.LastName)
            .MaximumLength(100)
            .WithMessage("Last name must not exceed 100 characters / Ten khong vuot qua 100 ky tu")
            .When(x => x.LastName != null);
    }
}

/// <summary>
/// EN: Validator for DeleteUserCommand.
/// VI: Validator cho DeleteUserCommand.
/// </summary>
public class DeleteUserCommandValidator : AbstractValidator<DeleteUserCommand>
{
    public DeleteUserCommandValidator()
    {
        RuleFor(x => x.UserId)
            .NotEmpty()
            .WithMessage("User ID is required / User ID la bat buoc");
    }
}
