Tag Archives: validation

XML syntax validation in Java [closed]

Questions: I’ve been trying to figure out how to check the syntax of an XML file, make sure all tags are closed, there’s no random characters, etc… All I care at this point is making sure there is no broken XML in the file. I’ve been looking at some SO posts like these… Validate an… Read More »

C# FP: Validation and execution with error handling functional way – space for improvement?

Questions: I’m new to functional way of thinking in C# (well… not limited to language). Let’s say there’s method: T LoadRecord<T>(int id) Concept 1. Validation When invalid input is given, I should return something like Either<IEnumerable<ValidationError>, T>. 2. Execution When calling DB/API/… which could throw, I should return Either<Exception, T>. 3. Some or none record… Read More »

Order of DependentRules in FluentValidation

Questions: I have the model like public class Command : IRequest<bool> { public int Id { get; set; } public int LabelId { get; set; } public int UserId { get; set; } } And fluent validator public class Validator : AbstractValidator<Command> { public Validator(DbContext dbContext) { RuleFor(q => q.LabelId).GreaterThan(0); RuleFor(q => q.UserId).GreaterThan(0); RuleFor(q =>… Read More »

FluentValidation.IValidatorFactory dependency injection not working in xunit test project

Questions: In my unit test with (xUnit) in the initializeFixture method I’m doing dependency injection using service collection, however the error is occurring: System.InvalidOperationException: Unable to resolve service for type ‘FluentValidation.IValidatorFactory’ while attempting to activate ‘FileSys.Shared.Core.Domain.Impl.Validator.FluentValidationService ‘. Note: the automapper injection is working. public InicializacaoFixture() { var serviceProvider = new ServiceCollection(); CrossCutting.IoC.Configuracao.InjecaoDependencia(serviceProvider); serviceProvider.AddAutoMapper(typeof(Mega.Application.DadoMestre.ConfigurationProfile).GetTypeInfo().Assembly); serviceProvider.AddDbContext<MegaContext>(options =>… Read More »