You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public class TimesheetsReportFilterModelValidator : AbstractValidator<TimesheetsReportFilterModel>
{
public TimesheetsReportFilterModelValidator(Reports.Resources.ITimesheetsReportsFilterLocalizer timesheetsReportsFilterLocalizer)
{
RuleFor(m => m.Period).Must(period => period.StartDate.HasValue).When(m => m.PeriodStartRequired).WithMessage(timesheetsReportsFilterLocalizer.PeriodStartRequired);
RuleFor(m => m.Period).Must(period => period.EndDate.HasValue).When(m => m.PeriodEndRequired).WithMessage(timesheetsReportsFilterLocalizer.PeriodEndRequired);
}
}
Where property "Period" is of type DateTimeRange. Then i use this property and bind it to a HxDateTimeRange: <HxInputDateRange InputSize="InputSize.Small" Label="@TimesheetsReportsFilterLocalizer.Period" @bind-Value="_model.Period" />
I then on initialization fill up these two fields, but when i clear one of those, then following error is thrown:
Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: More than one sibling of element 'span' has the same key value, 'Enter start date.'. Key values must be unique.
System.InvalidOperationException: More than one sibling of element 'span' has the same key value, 'Enter start date.'. Key values must be unique.
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.ThrowExceptionForDuplicateKey(Object key, RenderTreeFrame& frame)
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.BuildKeyToInfoLookup(DiffContext diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl)
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl)
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForFramesWithSameSequence(DiffContext& diffContext, Int32 oldFrameIndex, Int32 newFrameIndex)
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl)
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForFramesWithSameSequence(DiffContext& diffContext, Int32 oldFrameIndex, Int32 newFrameIndex)
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl)
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.ComputeDiff(Renderer renderer, RenderBatchBuilder batchBuilder, Int32 componentId, ArrayRange`1 oldTree, ArrayRange`1 newTree)
at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.RenderInExistingBatch(RenderQueueEntry renderQueueEntry)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()
Note that the "Enter start date" in:
More than one sibling of element 'span' has the same key value, 'Enter start date.'
is the message passed to the AbstractValidator in WithMessage() method.
A potential solution to this problem could be for this component to implement its own null checking based on some parameter.
The text was updated successfully, but these errors were encountered:
hakenr
changed the title
Using FluentValidationValidator to require non null value for HxDateTimeRange tries to create 2 spans with the same key.
[HxInputDateRange] Using FluentValidationValidator to require non null value for HxDateTimeRange tries to create 2 spans with the same key.
Dec 4, 2023
The InvalidOperationException during HxValidationMessage rendering was "fixed" in v4.3.5. It no longer fails on duplicate validation messages. It is out of scope of this issue where do the duplicate validation messages come from.
I have following code:
Where property "Period" is of type DateTimeRange. Then i use this property and bind it to a HxDateTimeRange:
<HxInputDateRange InputSize="InputSize.Small" Label="@TimesheetsReportsFilterLocalizer.Period" @bind-Value="_model.Period" />
I then on initialization fill up these two fields, but when i clear one of those, then following error is thrown:
Note that the "Enter start date" in:
is the message passed to the AbstractValidator in WithMessage() method.
A potential solution to this problem could be for this component to implement its own null checking based on some parameter.
The text was updated successfully, but these errors were encountered: