Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
215
UltraValidator custom condition
posted

I am trying to create my own custom Condition class from ICondition to do validation done by the code below, i.e. 2 regular expressions checked.  Unless there would be another way of doing, but with regular OperationCondition, I end up being able to check only one reg ex. Is there a way to add more than one OperationCondition to an UltraValidator? Ohterwise, would you have a sample for creating a CustomCondition : ICondition class?

        public virtual bool IsValid(out string reason)
        {
            if (CharacterValidator.IsMatch(Format))
            {
                if (FormatValidator.IsMatch(Format))
                {
                    reason = String.Empty;
                    return true;
                }
                else
                {
                    // Invalid construct
                    reason = Resources.Exception.FieldError_InvalidFormatSyntax;
                    return false;
                }
            }
            else
            {
                // Invalid characters found
                reason = String.Format(Resources.Exception.FieldError_InvalidFormatCharacters, 
                    CharacterValidator.GetAllowedCharsForDisplay());
                return false;
            }
        }

Thanks a lot
Parents
No Data
Reply
  • 12480
    Verified Answer
    Offline posted

    Hello,

    I have built a sample that shows how you can implement ICondition to validate based on a complex condition. In the sample, each text editor requires that the text is formatted like an Infragistics support case number (CAS-00000-AAAAAA), and it must contain the string "ASDF".

    Please let me know if you have any further questions.

    ValidatorCustomConditions.zip
Children