Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
field validator: only check for null representation if the string val…
…ue exceeds the field length (fixes #21019)
  • Loading branch information
jef-n committed Jan 23, 2019
1 parent daa05e5 commit 99904f1
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/gui/qgsfieldvalidator.cpp
Expand Up @@ -135,19 +135,20 @@ QValidator::State QgsFieldValidator::validate( QString &s, int &i ) const
}
else if ( mField.type() == QVariant::String )
{
// allow entering the NULL representation, which might be
// longer than the actual field
if ( !mNullValue.isEmpty() && !s.isEmpty() && s.size() < mNullValue.size() && s == mNullValue.left( s.size() ) )
return Intermediate;

if ( !mDefaultValue.isEmpty() && !s.isEmpty() && s.size() < mDefaultValue.size() && s == mDefaultValue.left( s.size() ) )
return Intermediate;

if ( s == mNullValue )
return Acceptable;

// allow entering the NULL representation, which might be longer than the actual field
if ( mField.length() > 0 && s.size() > mField.length() )
{
if ( !mNullValue.isEmpty() && !s.isEmpty() && s.size() < mNullValue.size() && s == mNullValue.left( s.size() ) )
return Intermediate;

if ( !mDefaultValue.isEmpty() && !s.isEmpty() && s.size() < mDefaultValue.size() && s == mDefaultValue.left( s.size() ) )
return Intermediate;

return Invalid;
}
}
else if ( mField.type() == QVariant::Date )
{
Expand Down

0 comments on commit 99904f1

Please sign in to comment.