This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MIT License | |
Copyright (c) 2022 Matt Johnson-Pint | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.app.PendingIntent; | |
import android.app.RecoverableSecurityException; | |
import android.content.ContentResolver; | |
import android.content.ContentValues; | |
import android.content.Context; | |
import android.content.IntentSender; | |
import android.database.Cursor; | |
import android.net.Uri; | |
import android.os.Build; | |
import android.provider.MediaStore; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Xamarin.Forms; | |
using Xamarin.Forms.Xaml; | |
namespace AwesomeApp.Xaml | |
{ | |
[ContentProperty(nameof(Type))] | |
public class EnumBindingSourceExtension : IMarkupExtension | |
{ | |
public Type Type { get; set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace ValidationsXFSample.ViewModels | |
{ | |
public class RegisterPageViewModel: INotifyPropertyChanged | |
{ | |
public ValidatableObject<string> FirstName { get; set; } = new ValidatableObject<string>(); | |
public ValidatableObject<string> LastName { get; set; } = new ValidatableObject<string>(); | |
public ValidatableObject<DateTime> BirthDay { get; set; } = new ValidatableObject<DateTime>() { Value = DateTime.Now }; | |
public ValidatableObject<string> PhoneNumber { get; set; } = new ValidatableObject<string>(); | |
public ValidatablePair<string> Email { get; set; } = new ValidatablePair<string>(); | |
public ValidatablePair<string> Password { get; set; } = new ValidatablePair<string>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
public class EntryLineValidationBehaviour : BehaviorBase<Entry> | |
{ | |
#region StaticFields | |
public static readonly BindableProperty IsValidProperty = BindableProperty.Create(nameof(IsValid), typeof(bool), typeof(EntryLineValidationBehaviour), true, BindingMode.Default, null, (bindable, oldValue, newValue) => OnIsValidChanged(bindable, newValue)); | |
#endregion | |
#region Properties | |
public bool IsValid | |
{ | |
get |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class InverseBoolConverter : IValueConverter | |
{ | |
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | |
{ | |
if (!(value is bool)) | |
{ | |
throw new InvalidOperationException("The target must be a boolean"); | |
} | |
return !(bool)value; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FirstValidationErrorConverter : IValueConverter | |
{ | |
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | |
{ | |
ICollection<string> errors = value as ICollection<string>; | |
return errors != null && errors.Count > 0 ? errors.ElementAt(0) : null; | |
} | |
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RegisterPageViewModel: INotifyPropertyChanged | |
{ | |
... | |
bool AreFieldsValid() | |
{ | |
bool isFirstNameValid = FirstName.Validate(); | |
bool isLastNameValid = LastName.Validate(); | |
bool isBirthDayValid = BirthDay.Validate(); | |
bool isPhoneNumberValid = PhoneNumber.Validate(); | |
bool isEmailValid = Email.Validate(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RegisterPageViewModel: INotifyPropertyChanged | |
{ | |
public ValidatableObject<string> FirstName { get; set; } = new ValidatableObject<string>(); | |
public ValidatableObject<string> LastName { get; set; } = new ValidatableObject<string>(); | |
public ValidatableObject<DateTime> BirthDay { get; set; } = new ValidatableObject<DateTime>() { Value = DateTime.Now }; | |
public ValidatableObject<string> PhoneNumber { get; set; } = new ValidatableObject<string>(); | |
public ValidatablePair<string> Email { get; set; } = new ValidatablePair<string>(); | |
public ValidatablePair<string> Password { get; set; } = new ValidatablePair<string>(); | |
public ValidatableObject<bool> TermsAndCondition { get; set; } = new ValidatableObject<bool>(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ValidatableObject<T> : IValidatable<T> | |
{ | |
public event PropertyChangedEventHandler PropertyChanged; | |
public List<IValidationRule<T>> Validations { get; } = new List<IValidationRule<T>>(); | |
public List<string> Errors { get; set; } = new List<string>(); | |
public bool CleanOnChange { get; set; } = true; |
NewerOlder