コード例 #1
0
ファイル: RegExAttribute.cs プロジェクト: epdumitru/mysqlib
		public override bool IsValid(ValidationContext context)
		{
			if (context.IsNull(context))
				return true;

			Match match = Validator.Match(context.Value.ToString());

			return match.Success && match.Value == context.Value.ToString();
		}
コード例 #2
0
		public override bool IsValid(ValidationContext context)
		{
			if (context.IsNull(context))
				return true;

			DateTime contextValue = Convert.ToDateTime(context.Value);
			DateTime testValue    = (DateTime)GetValue(context);

			return testValue > contextValue || !IsExclusive && testValue == contextValue;
		}
コード例 #3
0
        public override bool IsValid(ValidationContext context)
        {
            if (context.IsNull(context))
            {
                return(true);
            }

            Match match = Validator.Match(context.Value.ToString());

            return(match.Success && match.Value == context.Value.ToString());
        }
コード例 #4
0
        public override bool IsValid(ValidationContext context)
        {
            if (context.IsNull(context))
            {
                return(true);
            }

            DateTime contextValue = Convert.ToDateTime(context.Value);
            DateTime testValue    = (DateTime)GetValue(context);

            return(testValue > contextValue || !IsExclusive && testValue == contextValue);
        }
コード例 #5
0
 public override bool IsValid(ValidationContext context)
 {
     return(context.IsNull(context) == false);
 }
コード例 #6
0
 public override bool IsValid(ValidationContext context)
 {
     return(context.IsNull(context) || context.Value.ToString().Length >= _value);
 }
コード例 #7
0
        public override bool IsValid(ValidationContext context)
        {
            if (context.IsNull(context))
            {
                return(true);
            }

            object contextValue = context.Value;
            object testValue    = GetValue(context);

            if (contextValue is Int32)
            {
                Int32 tv = Convert.ToInt32(testValue);
                return(tv > (Int32)contextValue || !IsExclusive && tv == (Int32)contextValue);
            }

            if (contextValue is decimal)
            {
                decimal tv = Convert.ToDecimal(testValue);
                return(tv > (decimal)contextValue || !IsExclusive && tv == (decimal)contextValue);
            }

            if (contextValue is double)
            {
                double tv = Convert.ToDouble(testValue);
                return(tv > (double)contextValue || !IsExclusive && tv == (double)contextValue);
            }

            if (contextValue is float)
            {
                float tv = Convert.ToSingle(testValue);
                return(tv > (float)contextValue || !IsExclusive && tv == (float)contextValue);
            }

            if (contextValue is byte)
            {
                byte tv = Convert.ToByte(testValue);
                return(tv > (byte)contextValue || !IsExclusive && tv == (byte)contextValue);
            }

            if (contextValue is char)
            {
                char tv = Convert.ToChar(testValue);
                return(tv > (char)contextValue || !IsExclusive && tv == (char)contextValue);
            }

            if (contextValue is Int16)
            {
                Int16 tv = Convert.ToInt16(testValue);
                return(tv > (Int16)contextValue || !IsExclusive && tv == (Int16)contextValue);
            }

            if (contextValue is sbyte)
            {
                sbyte tv = Convert.ToSByte(testValue);
                return(tv > (sbyte)contextValue || !IsExclusive && tv == (sbyte)contextValue);
            }

            if (contextValue is UInt16)
            {
                UInt16 tv = Convert.ToUInt16(testValue);
                return(tv > (UInt16)contextValue || !IsExclusive && tv == (UInt16)contextValue);
            }

            if (contextValue is UInt32)
            {
                UInt32 tv = Convert.ToUInt32(testValue);
                return(tv > (UInt32)contextValue || !IsExclusive && tv == (UInt32)contextValue);
            }

            if (contextValue is Int64)
            {
                Int64 tv = Convert.ToInt64(testValue);
                return(tv > (Int64)contextValue || !IsExclusive && tv == (Int64)contextValue);
            }

            if (contextValue is UInt64)
            {
                UInt64 tv = Convert.ToUInt64(testValue);
                return(tv > (UInt64)contextValue || !IsExclusive && tv == (UInt64)contextValue);
            }

            return(true);
        }
コード例 #8
0
		public override bool IsValid(ValidationContext context)
		{
			if (context.IsNull(context))
				return true;

			object contextValue = context.Value;
			object testValue    = GetValue(context);

			if (contextValue is Int32)
			{
				Int32 tv = Convert.ToInt32(testValue);
				return tv > (Int32)contextValue || !IsExclusive && tv == (Int32)contextValue;
			}

			if (contextValue is decimal)
			{
				decimal tv = Convert.ToDecimal(testValue);
				return tv > (decimal)contextValue || !IsExclusive && tv == (decimal)contextValue;
			}

			if (contextValue is double)
			{
				double tv = Convert.ToDouble(testValue);
				return tv > (double)contextValue || !IsExclusive && tv == (double)contextValue;
			}

			if (contextValue is float)
			{
				float tv = Convert.ToSingle(testValue);
				return tv > (float)contextValue || !IsExclusive && tv == (float)contextValue;
			}

			if (contextValue is byte)
			{
				byte tv = Convert.ToByte(testValue);
				return tv > (byte)contextValue || !IsExclusive && tv == (byte)contextValue;
			}

			if (contextValue is char)
			{
				char tv = Convert.ToChar(testValue);
				return tv > (char)contextValue || !IsExclusive && tv == (char)contextValue;
			}

			if (contextValue is Int16)
			{
				Int16 tv = Convert.ToInt16(testValue);
				return tv > (Int16)contextValue || !IsExclusive && tv == (Int16)contextValue;
			}

			if (contextValue is sbyte)
			{
				sbyte tv = Convert.ToSByte(testValue);
				return tv > (sbyte)contextValue || !IsExclusive && tv == (sbyte)contextValue;
			}

			if (contextValue is UInt16)
			{
				UInt16 tv = Convert.ToUInt16(testValue);
				return tv > (UInt16)contextValue || !IsExclusive && tv == (UInt16)contextValue;
			}

			if (contextValue is UInt32)
			{
				UInt32 tv = Convert.ToUInt32(testValue);
				return tv > (UInt32)contextValue || !IsExclusive && tv == (UInt32)contextValue;
			}

			if (contextValue is Int64)
			{
				Int64 tv = Convert.ToInt64(testValue);
				return tv > (Int64)contextValue || !IsExclusive && tv == (Int64)contextValue;
			}

			if (contextValue is UInt64)
			{
				UInt64 tv = Convert.ToUInt64(testValue);
				return tv > (UInt64)contextValue || !IsExclusive && tv == (UInt64)contextValue;
			}

			return true;
		}
コード例 #9
0
		public override bool IsValid(ValidationContext context)
		{
			return context.IsNull(context) || context.Value.ToString().Length <= _value;
		}
コード例 #10
0
		public override bool IsValid(ValidationContext context)
		{
			return context.IsNull(context) == false;
		}