Skip to content

Commit

Permalink
feat: remove form validator
Browse files Browse the repository at this point in the history
  • Loading branch information
StepanSSA committed May 27, 2024
1 parent a6e23a5 commit 5368562
Showing 1 changed file with 1 addition and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Linq.Expressions;
using FluentValidation;
using FluentValidation;
using FluentValidation.Validators;
using Sitko.EditorJS.Blazor.Display;
using Sitko.EditorJS.Blocks;
Expand Down Expand Up @@ -49,26 +48,3 @@ public BlockInheritanceValidator<TModel> Add(IBlockDescriptor descriptor,
return this;
}
}

public abstract class AbstractEditorJSFormValidator<TForm> : AbstractValidator<TForm>
{
private readonly IEnumerable<IBlockDescriptor> blockDescriptors;
private readonly IEnumerable<IBlockValidator> validators;

public AbstractEditorJSFormValidator(IEnumerable<IBlockDescriptor> blockDescriptors,
IEnumerable<IBlockValidator> validators)
{
this.blockDescriptors = blockDescriptors;
this.validators = validators;
}

protected virtual IEnumerable<AbstractValidator<ContentBlock>>? AdditionalValidators => null;

protected AbstractEditorJSFormValidator<TForm> AddBlocksValidators(
Expression<Func<TForm, IEnumerable<ContentBlock>>> fieldSelector)
{
RuleForEach(fieldSelector)
.AddBlockValidators(blockDescriptors, validators, AdditionalValidators);
return this;
}
}

0 comments on commit 5368562

Please sign in to comment.