Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    pablopioli
    @pablopioli
    Sure! Still no problem using it!
    Peter Morris
    @mrpmorris
    Good :)
    Peter Morris
    @mrpmorris
    @SQL-MisterMagoo Just testing something, do you see this message?
    SQL-MisterMagoo
    @SQL-MisterMagoo
    yes
    Peter Morris
    @mrpmorris
    And you weren't in this room before, were you?
    Brett
    @brettwinters
    Hi Peter - I've been following your example for a custom-validator on blazor-university. As always very very useful, but I've run into a problem which I think is the same one dotnet/aspnetcore#11914. All works well until I add await Task.Delay(3000); to the ValidateAsync() - in fact I'm making an API call. This was supposed to have been fixed in 3.1 (I'm on .net5). After returning a failed validation and adding to the message store, the ValidationMessage is displaying the error ok, but I can still submit the form...any ideas. I haven't used your FluentValidator (trying to reduce payload since so far I only needed this once)
    Peter Morris
    @mrpmorris
    Call editContext.NotifyValidationStateChanged();
    Brett
    @brettwinters
    yeah, I'm doing that in the Validator in the AddValidationResult() method right after adding to the message store. Is that right?
    Peter Morris
    @mrpmorris
    If you do async then you have to do it after an await
    this is because the Blazor validation is not async so doesn't wait
    So when you've done your await, you have to tell it to check if its validation state has changed
    well, tell it that it has
    Brett
    @brettwinters
    Yes, its definately not waiting. Both my FieldChanged and ValidationRequested are both async void. inside these methods I await Validate() and then pass the result to void AddValidationResult(errors). So I think I'm doing that...why would ValidationMessage/ValidationSummary display the error and yet not prevent the submit?
    Peter Morris
    @mrpmorris
    that's why then
    never do async void
    better to do Task Whatever and ignore the result
    but anyway
    After your last await call EditContext.NotifyValidationStateChanged()
    Brett
    @brettwinters
    but they're event handlers, and I just copied your code here haha.
    Well if I change the handlers to EventHandler<ValidationRequestedEventArgs> ValidationRequestedAsync => async (sender, args) => await ValidationRequested(sender, args); and EventHandler<FieldChangedEventArgs> FieldChangedAsync => async (sender, args) => await FieldChanged(sender, args); and change the ValidationRequested and FieldChanged to return Task, I have the same issue.
    I might have to use fluent validation then haha. No issues with async calls (MustAsync(async () => ..) using your library right?
    Peter Morris
    @mrpmorris
    I think I have a demo for that
    but you shouldn't need to use fluent to achieve that
    Have you tried adding an error and then calling NotifyValidationStateChanged?
    Brett
    @brettwinters
    yeah, if I add the error before await Task.Delay() then it works. After task.delay its only in the validationmessage
    I'm calling CurrentEditContext.NotifyValidationStateChanged(); everywhere now
    Peter Morris
    @mrpmorris
    async methods are synchronous until the point you await
    so anything you do before await will occur immediately before returning to the caller
    Brett
    @brettwinters
    hmmmmm yes, I think thats normal. oh, if I don't clear the ValidationMessageStore.Clear(); in the ValidationRequested() then it does prevent the submit. (but of course just keeps appending the errors to the store).
    Peter Morris
    @mrpmorris
    I suppose the problem is that after the sync operation Blazor thinks it has finished validating
    So you'd have to set a boolean to say "this is validating, disable the submit button"
    which you reset when the async validations have completed
    Brett
    @brettwinters
    yes, thats an option but I think I will have to live with it (my server validator will return errors anyway if the user submits). I noticed in the EditForm Source in theHandleSubmitAsync()that the developer has included the comment var isValid = _editContext.Validate(); // This will likely become ValidateAsync later so I guess I'll wait. As always, thanks for your help Peter.
    Peter Morris
    @mrpmorris
    Yw
    pablopioli
    @pablopioli

    So, unfortunately I need to use this channel to discuss an issue. I upgraded to Net 5 and found the same problem as mrpmorris/blazor-validation#19

    What is blocking this issue? The Net 5 sample?

    pablopioli
    @pablopioli
    OK, seeing the discussion on multitargetting on the Blazor channel. If I can help in something I'm in.
    Peter Morris
    @mrpmorris
    I'll address it tonight
    Peter Morris
    @mrpmorris
    blazor validation 1.5.0-beta-1 supports Net5
    pablopioli
    @pablopioli
    Cool, trying it ASAP
    pablopioli
    @pablopioli
    Yes, working as expected. Thanks for resolving the issue so fast.
    Peter Morris
    @mrpmorris
    yw
    Peter Morris
    @mrpmorris
    1.5.0 released
    Peter Morris
    @mrpmorris
    1.6.0 released
    pablopioli
    @pablopioli

    Is there a way to validate and show the ValidationMessage tag for an specific field?

    A field is the source of common errors and I want to show it to the user as soon as posible. Before the submit is triggered and all fields are evaluated.

    pablopioli
    @pablopioli

    var fieldIdentifier = new FieldIdentifier(Model, "xxx"); EditContext.ValidateProperty(fieldIdentifier); EditContext.NotifyValidationStateChanged();

    I came out with this code. No blazor-validation related, sorry.

    Peter Morris
    @mrpmorris
    :)
    pablopioli
    @pablopioli

    Just a warning.

    FluentValidation 10 was released yesterday. In the release notes states that a lot of internal changes happened.

    So I tried BlazorValidation and yes, it's not working with version 10.

    No rush to update to v10, so still haven't looked if I can find where the problem is.

    Peter Morris
    @mrpmorris
    Hmmmm
    Thanks