public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { MaskAttribute maskAttribute = this.ExtractMaskAttribute(bindingContext); if (maskAttribute != null && maskAttribute.ClearMaskSubmit) { object value = base.BindModel(controllerContext, bindingContext); string newValue = maskAttribute.CleanValue(value.ToString()); return(newValue); } return(base.BindModel(controllerContext, bindingContext)); }
public void CleanValue_CNPJ_Test() { MaskAttribute mask = new MaskAttribute("99.999.999/9999-99"); Assert.AreEqual("68837346000182", mask.CleanValue("68.837.346/0001-82")); }
public void CleanValue_MultMask_CPF_Test() { MaskAttribute mask = new MaskAttribute(new string[] { "99.999.999/9999-99", "999.999.999-99" }); Assert.AreEqual("07992474643", mask.CleanValue("079.924.746-43")); }
public void CleanValue_MultMask_Telefone_9_Dig_Test() { MaskAttribute mask = new MaskAttribute(new string[] { "(99) 9999-9999", "(31) 99999-9999" }); Assert.AreEqual("31987423236", mask.CleanValue("(31) 98742-3236")); }
public void CleanValue_CPF_Test() { MaskAttribute mask = new MaskAttribute("999.999.999-99"); Assert.AreEqual("07992474643", mask.CleanValue("079.924.746-43")); }