IsValid() публичный Метод

Determines whether the specified value of the object is valid.
public IsValid ( object value ) : bool
value object The value of the object to validate.
Результат bool
Пример #1
0
		public void IsValid ()
		{
			var sla = new CreditCardAttribute ();

			Assert.IsTrue (sla.IsValid (null), "#A1-1");
			Assert.IsTrue (sla.IsValid (String.Empty), "#A1-2");
			Assert.IsFalse (sla.IsValid ("string"), "#A1-3");
			Assert.IsTrue (sla.IsValid ("378282246310005"), "#A1-4");
			Assert.IsTrue (sla.IsValid ("3782-8224-6310-005"), "#A1-5");
			Assert.IsTrue (sla.IsValid ("371449635398431"), "#A-6");
			Assert.IsFalse (sla.IsValid ("371449635498431"), "#A-6b");
			Assert.IsFalse (sla.IsValid (true), "#A1-7");
			Assert.IsFalse (sla.IsValid (DateTime.Now), "#A1-8");
		}
        public void IsValidTests()
        {
            var attribute = new CreditCardAttribute();

            Assert.IsTrue(attribute.IsValid(null));                  // Don't check for required
            Assert.IsTrue(attribute.IsValid("0000000000000000"));    // Simplest valid value
            Assert.IsTrue(attribute.IsValid("1234567890123452"));    // Good checksum
            Assert.IsTrue(attribute.IsValid("1234-5678-9012-3452")); // Good checksum, with dashes
            Assert.IsTrue(attribute.IsValid("1234 5678 9012 3452")); // Good checksum, with spaces
            Assert.IsTrue(attribute.IsValid("541234567890125"));
            Assert.IsTrue(attribute.IsValid("4408041234567893"));
            Assert.IsTrue(attribute.IsValid("4417123456789113"));

            Assert.IsFalse(attribute.IsValid("0000000000000001"));   // Bad checksum
            Assert.IsFalse(attribute.IsValid("0000-0000-0000-0001"));
            Assert.IsFalse(attribute.IsValid("1234567890123456"));
            Assert.IsFalse(attribute.IsValid("558987100150")); //too short
            Assert.IsFalse(attribute.IsValid("---"));
            Assert.IsFalse(attribute.IsValid("AA17123456789112"));
            Assert.IsFalse(attribute.IsValid("4417123456789112"));
            Assert.IsFalse(attribute.IsValid("4408041234567890"));
            Assert.IsFalse(attribute.IsValid("4408041234567890ab"));
            Assert.IsFalse(attribute.IsValid("4408 0412 3456 7890"));
            Assert.IsFalse(attribute.IsValid(0));                    // Non-string
        }