Add validation rules to detect errors on property changes. You can add Error, Warning or Information results for validations.
static RegisterNewContactEditorVM()
{
RegisterProperty(x => x.Email)
.Validate<ValidEmail>(message: "Wrong email format"); // If not indicated, Error kind is assumed by default
.Validate((vm, val) => existsInMyUsersDB(val), ValidationKind.Error, "email already registered"));
RegisterProperty(x => x.Password)
.Validate((vm, val) => weakness(val) == Weakness.Low, ValidationKind.Warning, "Weak password"))
.Validate((vm, val) => weakness(val) == Weakness.High, ValidationKind.Error, "Unacceptable password"));
RegisterProperty(x => x.MultiFactorAddresses)
.Validate((vm, col) => col.Count < 1, ValidationKind.Warning, "Strong authentication have 2 or more factors"))
.Validate((vm, col) => col.Count == 0, ValidationKind.Error, "At least one more factor is needed"));
}
public string Email { set => SetValue(value); get => GetValue<string>(); }
public string Password { set => SetValue(value); get => GetValue<string>(); }
public ObservableCollection<Address> MultiFactorAddresses { get => GetCollection<ObservableCollection<Address>>(); }