using System.Text.RegularExpressions;
public static void Main()
var pinLength = new PinMobile("1236").Pin;
var pinFormat = new PinMobile("123456").Pin;
var pinValid = new PinMobile("353123").Pin;
Console.WriteLine($"Pin {pinValid} Valid");
var a = new CustomerSetPinMobile
CustomerId = Guid.NewGuid(),
Pin = new PinMobile(pinValid)
public string Pin {get;set;}
public PinMobile(string pin)
Console.WriteLine($"pin {pin} Length isn't valid.");
private void PinFormat(string pin)
var checkPinRegularExpressions = new Regex(@"^(?!(\d)\1{4}|(?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)|9(?=0)){5}\d$|(?:0(?=9)|1(?=0)|2(?=1)|3(?=2)|4(?=3)|5(?=4)|6(?=5)|7(?=6)|8(?=7)|9(?=8)){5}\d$)\d{6}$");
if (!checkPinRegularExpressions.IsMatch(pin))
Console.WriteLine($"pin {pin} format isn't valid.");
public class CustomerSetPinMobile
public Guid CustomerId {get;set;}
public PinMobile Pin {get;set;}