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