40 wxTextValidator( wxFILTER_EXCLUDE_CHAR_LIST, aValue )
46 wxString excludes( wxT(
"\r\n\t" ) );
51 excludes += wxT(
" " );
55 excludes += wxT(
"/" );
58 long style = GetStyle();
65 style |= wxFILTER_EMPTY;
69 SetCharExcludes( excludes );
74 wxTextValidator( aValidator )
84 if( !m_validatorWindow->IsEnabled() )
87 wxTextEntry*
const text = GetTextEntry();
92 wxString val(
text->GetValue() );
95 if( HasFlag( wxFILTER_EMPTY ) && val.empty() )
96 msg.Printf(
_(
"The value of the field cannot be empty." ) );
98 if( HasFlag( wxFILTER_EXCLUDE_CHAR_LIST ) && ContainsExcludedCharacters( val ) )
100 wxArrayString badCharsFound;
102#if wxCHECK_VERSION( 3, 1, 3 )
103 for(
const wxUniCharRef& excludeChar : GetCharExcludes() )
105 if( val.Find( excludeChar ) != wxNOT_FOUND )
107 if( excludeChar ==
'\r' )
108 badCharsFound.Add(
_(
"carriage return" ) );
109 else if( excludeChar ==
'\n' )
110 badCharsFound.Add(
_(
"line feed" ) );
111 else if( excludeChar ==
'\t' )
112 badCharsFound.Add(
_(
"tab" ) );
113 else if( excludeChar ==
' ' )
114 badCharsFound.Add(
_(
"space" ) );
116 badCharsFound.Add( wxString::Format( wxT(
"'%s'" ), excludeChar ) );
120 for(
const wxString& excludeChar : GetExcludes() )
122 if( val.Find( excludeChar ) != wxNOT_FOUND )
124 if( excludeChar == wxT(
"\r" ) )
125 badCharsFound.Add(
_(
"carriage return" ) );
126 else if( excludeChar == wxT(
"\n" ) )
127 badCharsFound.Add(
_(
"line feed" ) );
128 else if( excludeChar == wxT(
"\t" ) )
129 badCharsFound.Add(
_(
"tab" ) );
130 else if( excludeChar == wxT(
" " ) )
131 badCharsFound.Add(
_(
"space" ) );
133 badCharsFound.Add( wxString::Format( wxT(
"'%s'" ), excludeChar ) );
140 for(
size_t i = 0; i < badCharsFound.GetCount(); i++ )
142 if( !badChars.IsEmpty() )
144 if( badCharsFound.GetCount() == 2 )
146 badChars +=
_(
" or " );
150 if( i < badCharsFound.GetCount() - 2 )
151 badChars +=
_(
", or " );
153 badChars += wxT(
", " );
157 badChars += badCharsFound.Item( i );
163 msg.Printf(
_(
"The reference designator cannot contain %s character(s)." ), badChars );
167 msg.Printf(
_(
"The value field cannot contain %s character(s)." ), badChars );
171 msg.Printf(
_(
"The footprint field cannot contain %s character(s)." ), badChars );
175 msg.Printf(
_(
"The datasheet field cannot contain %s character(s)." ), badChars );
179 msg.Printf(
_(
"The sheet name cannot contain %s character(s)." ), badChars );
183 msg.Printf(
_(
"The sheet filename cannot contain %s character(s)." ), badChars );
187 msg.Printf(
_(
"The field cannot contain %s character(s)." ), badChars );
193 msg.Printf(
_(
"The reference designator cannot contain text variable references" ) );
198 m_validatorWindow->SetFocus();
200 wxMessageBox( msg,
_(
"Field Validation Error" ), wxOK | wxICON_EXCLAMATION, aParent );
221 if( str.Length() == 1 )
230 return _(
"Signal name contains '{' and '}' but is not a valid bus name" );
232 else if( str.Contains(
'[' ) || str.Contains(
']' ) )
235 return _(
"Signal name contains '[' or ']' but is not a valid bus name." );
wxString IsValid(const wxString &aVal) const override
static bool ParseBusGroup(const wxString &aGroup, wxString *name, std::vector< wxString > *aMemberList)
Parse a bus group label into the name and a list of components.
static bool ParseBusVector(const wxString &aBus, wxString *aName, std::vector< wxString > *aMemberList)
Parse a bus vector (e.g.
A text control validator used for validating the text allowed in library and schematic symbol fields.
SCH_FIELD_VALIDATOR(bool aIsLibEditor, int aFieldId, wxString *aValue=nullptr)
virtual bool Validate(wxWindow *aParent) override
Override the default Validate() function provided by wxTextValidator to provide better error messages...
static wxRegEx m_busGroupRegex
wxString IsValid(const wxString &aVal) const override
Definitions of control validators for schematic dialogs.
@ DATASHEET_FIELD
name of datasheet
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".