- wxString errormsg;
- switch (m_validatorStyle)
- {
- case wxFILTER_NONE:
- // nothing to do...
- break;
-
- case wxFILTER_INCLUDE_LIST:
- if ( m_includes.Index(val) == wxNOT_FOUND )
- errormsg = _("'%s' is invalid");
- break;
-
- case wxFILTER_EXCLUDE_LIST:
- if ( m_excludes.Index(val) != wxNOT_FOUND )
- errormsg = _("'%s' is invalid");
- break;
-
- case wxFILTER_ASCII:
- if ( !val.IsAscii() )
- errormsg = _("'%s' should only contain ASCII characters.");
- break;
-
- case wxFILTER_ALPHA:
- if ( !wxIsAlpha(val) )
- errormsg = _("'%s' should only contain alphabetic characters.");
- break;
-
- case wxFILTER_ALPHANUMERIC:
- if ( !wxIsAlphaNumeric(val) )
- errormsg = _("'%s' should only contain alphabetic or numeric characters.");
- break;
-
- case wxFILTER_NUMERIC:
- if ( !wxIsNumeric(val) )
- errormsg = _("'%s' should be numeric.");
- break;
-
- case wxFILTER_INCLUDE_CHAR_LIST:
- if ( !IsInCharIncludes(val) )
- errormsg = _("'%s' is invalid");
- break;
-
- case wxFILTER_EXCLUDE_CHAR_LIST:
- if ( !IsNotInCharExcludes(val) )
- errormsg = _("'%s' is invalid");
- break;
-
- default:
- wxFAIL_MSG("invalid text validator style");
- }
-
- if (pErr)
- *pErr = errormsg;
-
- return errormsg.empty();
+ // wxFILTER_EMPTY is checked for in wxTextValidator::Validate
+
+ if ( HasFlag(wxFILTER_ASCII) && !val.IsAscii() )
+ return _("'%s' should only contain ASCII characters.");
+ if ( HasFlag(wxFILTER_ALPHA) && !wxStringCheck<wxIsalpha>(val) )
+ return _("'%s' should only contain alphabetic characters.");
+ if ( HasFlag(wxFILTER_ALPHANUMERIC) && !wxStringCheck<wxIsalnum>(val) )
+ return _("'%s' should only contain alphabetic or numeric characters.");
+ if ( HasFlag(wxFILTER_DIGITS) && !wxStringCheck<wxIsdigit>(val) )
+ return _("'%s' should only contain digits.");
+ if ( HasFlag(wxFILTER_NUMERIC) && !wxIsNumeric(val) )
+ return _("'%s' should be numeric.");
+ if ( HasFlag(wxFILTER_INCLUDE_LIST) && m_includes.Index(val) == wxNOT_FOUND )
+ return _("'%s' is invalid");
+ if ( HasFlag(wxFILTER_INCLUDE_CHAR_LIST) && !ContainsOnlyIncludedCharacters(val) )
+ return _("'%s' is invalid");
+ if ( HasFlag(wxFILTER_EXCLUDE_LIST) && m_excludes.Index(val) != wxNOT_FOUND )
+ return _("'%s' is invalid");
+ if ( HasFlag(wxFILTER_EXCLUDE_CHAR_LIST) && ContainsExcludedCharacters(val) )
+ return _("'%s' is invalid");
+
+ return wxEmptyString;