Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: DatePicker validaton not working for Dates #5508

Closed
stiankroknes opened this issue May 14, 2024 · 0 comments
Closed

[Bug]: DatePicker validaton not working for Dates #5508

stiankroknes opened this issue May 14, 2024 · 0 comments
Assignees
Labels
Type: Bug 🐞 Something isn't working
Projects
Milestone

Comments

@stiankroknes
Copy link

Blazorise Version

1.5.2

What Blazorise provider are you running on?

None

Link to minimal reproduction or a simple code snippet

Steps to reproduce

What is expected?

Validation should work.

What is actually happening?

When using DatePicker with @bind-Dates (selection mode Range or Multiple) the validation does not work and I get error:

Unable to determine the validator type.

After looking in the source it seems like only the Date input is initialized for validation in SetParametersAsync (DatePicker.razor.cs), thus Dates input validation will not work. Probably need this:

if ( parameters.TryGetValue<Expression<Func<TValue>>>( nameof( DatesExpression ), out var datesExpression ) )
    await ParentValidation.InitializeInputExpression( datesExpression );

Workaround: inherit DatePicker and override SetParametersAsync:

    public override async Task SetParametersAsync(ParameterView parameters)
    {
        if (parameters.TryGetValue<Validation>(nameof(ParentValidation), out var parentValidation) && parentValidation is not null)
        {
            if (parameters.TryGetValue<Expression<Func<IReadOnlyList<TValue>>>>(nameof(DatesExpression), out var expression))
            {
                await parentValidation.InitializeInputExpression(expression);
            }
        }

        await base.SetParametersAsync(parameters);
    }

What browsers do you see the problem on?

No response

Any additional comments?

No response

@stiankroknes stiankroknes added the Type: Bug 🐞 Something isn't working label May 14, 2024
@stsrki stsrki added this to the 1.5 support milestone May 15, 2024
@stsrki stsrki added this to 🔙 Backlog in Support via automation May 15, 2024
@stsrki stsrki closed this as completed May 29, 2024
Support automation moved this from 🔙 Backlog to ✔ Done May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug 🐞 Something isn't working
Projects
Support
  
✔ Done
Development

No branches or pull requests

2 participants