Skip to content

Instantly share code, notes, and snippets.

@ameerthehacker
Last active August 25, 2018 18:07
Show Gist options
  • Save ameerthehacker/ef8f3bfefc0cca93fd6e4a6e4ced3ea4 to your computer and use it in GitHub Desktop.
Save ameerthehacker/ef8f3bfefc0cca93fd6e4a6e4ced3ea4 to your computer and use it in GitHub Desktop.
Format validator implementation for IValidator
using System.Text.RegularExpressions;
using XamarinFormValidation.Validators.Contracts;
namespace XamarinFormValidation.Validators.Implementations
{
public class FormatValidator: IValidator
{
public string Message { get; set; } = "Invalid format";
public string Format { get; set; }
public bool Check(string value)
{
if (!string.IsNullOrEmpty(value))
{
Regex format = new Regex(Format);
return format.IsMatch(value);
}
else
{
return false;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment