Skip to content

Instantly share code, notes, and snippets.

@Char0394
Created October 26, 2017 22:41
Show Gist options
  • Select an option

  • Save Char0394/704958e04e973c616a1552dfd9ecbcf5 to your computer and use it in GitHub Desktop.

Select an option

Save Char0394/704958e04e973c616a1552dfd9ecbcf5 to your computer and use it in GitHub Desktop.
using System;
using System.ComponentModel;
using System.Windows.Input;
using EntryValidationBorder.Models;
using Xamarin.Forms;
namespace EntryValidationBorder.ViewModels
{
public class MainPageViewModel: INotifyPropertyChanged
{
public User User { get; set; }
public bool ErrorMessageVisiliby { get; set; }
public ICommand OnValidationCommand { get; set; }
public MainPageViewModel()
{
User = new User();
OnValidationCommand = new Command((obj) =>
{
User.FirstName.NotValidMessageError = "Name is required";
User.FirstName.IsNotValid = string.IsNullOrEmpty(User.FirstName.Name);
User.Email.NotValidMessageError = "Email is required";
User.Email.IsNotValid = string.IsNullOrEmpty(User.Email.Name);
if(string.IsNullOrEmpty(User.Password.Name)){
User.Password.NotValidMessageError = "Password is required";
User.Password.IsNotValid = true;
}else if (User.Password.Name.Length < 5)
{
User.Password.NotValidMessageError = "Password must have more than 5 charcteres";
User.Password.IsNotValid = true;
}else{
User.Password.IsNotValid = false;
}
});
}
public event PropertyChangedEventHandler PropertyChanged;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment