My Blazor application has two forms in different components. Both forms use he same view model. Though the model is the same, different fields are displayed in the components. E.g. the first component's form does not have the UnitPrice field, but the second does. I use a simple validation:
[Required(ErrorMessage = "Unit Price is required.")]
[Range(0.01, double.MaxValue, ErrorMessage = "Unit Price must be greater than 0")]
public double UnitPrice { get; set; }
Unfortunately, when the first form is displayed and submitted, the missing field is validated, and the validation fails. Is there any way to do it without splitting the model or using custom validation?