-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Resolved because the question asked by the original author has been answered.Status: Resolvedarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor Componentsfeature-blazor-form-validationThis issue is related to forms validation in BlazorThis issue is related to forms validation in Blazor
Description
Is there an existing issue for this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe the problem.
is it possible (is there plans to implement) to add a validation error like in MVC AddModelError(key, errorMessage) ?
for now I have temporary workaround which looks like this:
public class CustomValid : ValidationAttribute
{
public override bool IsValid(object value)
{
if (value is null) return true;
ErrorMessage = (string)value;
return false;
}
}
ViewModel:
[CustomValid]
public string Vld1 { get; set; }
save code:
input.Vld1 = input.Name == "Foo" ? "Name not unique" : null;
if (!editContext.Validate()) ...
Describe the solution you'd like
EditContext.AddFieldError(fieldName, errorMessage)
Additional context
No response
Metadata
Metadata
Assignees
Labels
✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Resolved because the question asked by the original author has been answered.Status: Resolvedarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor Componentsfeature-blazor-form-validationThis issue is related to forms validation in BlazorThis issue is related to forms validation in Blazor