I have a Maui app with a view model. The ViewModel has the following property:
[ObservableProperty]
public UserAccountDTO userAccount = new UserAccountDTO();
UserAccountDTO has the following property:
public partial class UserAccountDTO: ObservableValidator
{
[Required(AllowEmptyStrings = false, ErrorMessage = "Firstname required")]
[MaxLength(10, ErrorMessage = "Text length is maximum 10!")]
[ObservableProperty]
public string firstName;
}
I have the firstName bound to an Entry.
In the VM, when I call ValidateAllProperties() I don't get any errors coming back from this class. I.e. if FirstName is blank HasErrors is still false.
[RelayCommand]
private async void CreateAccountPressed()
{
ValidateAllProperties();
string Error = string.Empty;
if (HasErrors)
Error = string.Join(Environment.NewLine, GetErrors().Select(e => e.ErrorMessage));
}
Am I missing something?
Thanks