Example #1
0
        /*
         * Validate user supplied value against a regular expression.
         *
         * Only validate if regex is supplied and user supplies a value.
         *
         * Return false if validation fails for any field.
         *
         */
        protected bool ValidateRegEx2(DataFieldControl dfc, ArrayList notifications)
        {
            if ((dfc.RegEx != string.Empty) && dfc.FieldTextBoxText.Trim() != string.Empty)
            {
                if (Regex.IsMatch(dfc.FieldTextBoxText, dfc.RegEx) == false)
                {
                    string err = dfc.RegExDescription;

                    // set a default value for error text if none specified
                    if (err == string.Empty)
                    {
                        err = "Invalid value.";
                    }

                    dfc.AddError(err);
                    notifications.Add(string.Format("Error in field {0}. ", Shorten(dfc.FieldLabelText)) + err);
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            else
            {
                return(true);
            }
        }
Example #2
0
 protected bool ValidateInsertRequired2(DataFieldControl dfc, ArrayList notifications)
 {
     if (dfc.IsInsertValueRequired && (dfc.FieldTextBoxText.Trim() == string.Empty))
     {
         dfc.AddError(string.Format("{0} is required.", Shorten(dfc.FieldLabelText)));
         notifications.Add(string.Format("{0} is required.", Shorten(dfc.FieldLabelText)));
         return(false);
     }
     else
     {
         return(true);
     }
 }
Example #3
0
 /*
  * Verify that any user supplied value in dataEntryFields matches its
  * specified fielddatatype.  All fields must specify a fieldDataType.
  *
  * Only validate if user supplies a value.
  *
  * Put any errors in notifications.
  *
  * Return FALSE if any validation errors occur.
  *
  */
 protected bool ValidateFieldType2(DataFieldControl dfc, ArrayList notifications)
 {
     if (dfc.FieldTextBoxText.Trim() != string.Empty &&
         FieldTypeUtil.CheckType(dfc.FieldTextBoxText.Trim(), dfc.FieldDataType) == false)
     {
         dfc.AddError(string.Format("{0} is not a valid {1} value.", Shorten(dfc.FieldLabelText), dfc.FieldDataType));
         notifications.Add(string.Format("{0} is not a valid {1} value.", Shorten(dfc.FieldLabelText), dfc.FieldDataType));
         return(false);
     }
     else
     {
         return(true);
     }
 }
Example #4
0
 /*
  * Verify that the user supplied value in dataEntryFields matches its
  * specified validList.  validLIst is a comma delimited string of values of
  * type fieldDataType. Items in list might be in form x thru y.  See RangeList class
  * for details.
  *
  * Only validate fields that supply a value for validList
  * AND where the user has supplied a value.
  *
  * Validate user entered values against fielddatatype before calling this function.
  *
  * Put any errors in notifications.
  *
  * Return FALSE if any validation errors occur.
  *
  */
 protected bool ValidateValidList2(DataFieldControl dfc, ArrayList notifications)
 {
     if (dfc.ValidList != string.Empty && dfc.FieldTextBoxText.Trim() != string.Empty)
     {
         if (dfc.ValidListRangeList.InList(dfc.FieldTextBoxText.Trim()) == false)
         {
             dfc.AddError(string.Format("{0} must be in {1}.", Shorten(dfc.FieldLabelText), dfc.ValidList));
             notifications.Add(string.Format("{0} must be in {1}.", Shorten(dfc.FieldLabelText), dfc.ValidList));
             return(false);
         }
         else
         {
             return(true);
         }
     }
     else
     {
         return(true);
     }
 }
Example #5
0
 /*
  * Verify that user supplied value is within the range specified by minVal and maxVal.
  *
  * Only validate fields that have a user supplied value AND have a specified min or max val.
  *
  * Validate the user supplied value against the fieldtype before calling.
  *
  * Return FALSE if errors occur.
  *
  */
 protected bool ValidateMinMaxBetween2(DataFieldControl dfc, ArrayList notifications)
 {
     // only check if minval or maxval exist AND user supplied a value
     if ((dfc.MaxVal != string.Empty || dfc.MinVal != string.Empty) &&
         dfc.FieldTextBoxText.Trim() != string.Empty)
     {
         if (CheckMinMaxBetween(dfc) == false)
         {
             // construct the appropriate message
             string msg;
             if (dfc.MaxVal != string.Empty && dfc.MinVal != string.Empty)
             {
                 msg = string.Format("{0} value must between {1} and {2}.", Shorten(dfc.FieldLabelText), dfc.MinVal, dfc.MaxVal);
             }
             else if (dfc.MinVal != string.Empty)
             {
                 msg = string.Format("{0} value must be greater than or equal to {1}.", Shorten(dfc.FieldLabelText), dfc.MinVal);
             }
             else
             {
                 msg = string.Format("{0} value must be less than or equal to {1}.", Shorten(dfc.FieldLabelText), dfc.MaxVal);
             }
             dfc.AddError(msg);
             notifications.Add(msg);
             return(false);
         }
         else
         {
             return(true);
         }
     }
     else
     {
         return(true);
     }
 }