Last active
August 25, 2018 18:07
-
-
Save ameerthehacker/ef8f3bfefc0cca93fd6e4a6e4ced3ea4 to your computer and use it in GitHub Desktop.
Format validator implementation for IValidator
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.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