I'm new to RxUI, coming from Jounce, trying to do field validation the best way. Cant seem to find docs on the best way to do validation in RxUI.
You have some view model that derives from ReactiveValidatedObject.
It has properties like:
[Required]
[StringLength(9,MinimumLength=9)]
public string CUSIP
{
get { return _CUSIP; }
set { this.RaiseAndSetIfChanged(x => x.CUSIP, value); }
}
How do I make sure that validation errors show in my UI on the controls that have the errors when I go to run the save command?
this.SaveCommand = new ReactiveCommand();
this.SaveCommand.Subscribe(_ =>
{
});
... I'm used to Jounce and doing stuff like:
private string _oldPassword;
public string OldPassword
{
get { return _oldPassword; }
set { _oldPassword = value;
ValidateOldPassword();
RaisePropertyChanged(() => OldPassword);
}
}
private void ValidateOldPassword()
{
ClearErrors(() => OldPassword);
if (string.IsNullOrEmpty(OldPassword))
SetError(() => OldPassword, "Old Password is required.");
if (OldPassword != UserContext.Password)
SetError(() => OldPassword, "Old Password is incorrect.");
}
Thanks for any help. :)