using FluentValidation.Results; using PoweredSoft.CQRS.GraphQL.Abstractions; using System.Collections.Generic; namespace PoweredSoft.CQRS.GraphQL.FluentValidation { public class GraphQLFluentValidationResult : IGraphQLValidationResult { public bool IsValid => Errors.Count == 0; public List Errors { get; } = new List(); public static GraphQLFluentValidationResult From(ValidationResult result) { var model = new GraphQLFluentValidationResult(); foreach (var error in result.Errors) { var fieldError = new GraphQLFieldError { Field = error.PropertyName }; fieldError.Errors.Add(error.ErrorMessage); model.Errors.Add(fieldError); } return model; } } }