using FluentValidation;
using Monitoring.Contracts;
using Monitoring.Core.Domain.AssetManagement;

namespace Monitoring.Features.Events.Create;

public class CreateEventValidator : AbstractValidator<CreateEventRequest>
{
	public CreateEventValidator()
	{
		_ = RuleFor(x => x.AssetId).NotEmpty();

		_ = RuleFor(x => x.Code).GreaterThanOrEqualTo(0).LessThan(1_000_000);

		_ = RuleFor(x => x.Token).NotEmpty();

		_ = RuleFor(x => x.AutoAssetCreating!.AssetName)
			.NotEmpty()
			.NotNull()
			.Length(AssetName.MinLength, AssetName.MaxLength)
			.When(x => x.AutoAssetCreating is not null);
	}
}
