Example #1
0
        protected override bool Validate(string value, out string errorMessage)
        {
            int  val;
            bool valid = int.TryParse(value, out val);

            errorMessage = string.Empty;
            if (!valid)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("Invalid Value (Valid Value Format: \"");
                sb.Append(FormatPatterns.GetIntFormatPattern());
                sb.Append("\")");
                errorMessage = sb.ToString();
            }
            return(valid);
        }
Example #2
0
        protected virtual bool Validate(string value, out string errorMessage)
        {
            double val;
            bool   valid = double.TryParse(value, out val);

            errorMessage = string.Empty;
            if (!valid)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("Invalid Value (Valid Value Format: \"");
                sb.Append(FormatPatterns.GetDoubleFormatPattern());
                sb.Append("\")");
                errorMessage = sb.ToString();
            }
            return(valid);
        }
Example #3
0
        protected virtual bool Validate(string value, out string errorMessage)
        {
            TimeSpan val;
            bool     valid = TimeSpan.TryParseExact(value, "c", CultureInfo.CurrentCulture, out val);

            errorMessage = string.Empty;
            if (!valid)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("Invalid Value (Valid Value Format: \"");
                sb.Append(FormatPatterns.GetTimeSpanFormatPattern());
                sb.Append("\")");
                errorMessage = sb.ToString();
            }
            return(valid);
        }