Skip to content
Permalink
Browse files

field validator: only check for null representation if the string val…

…ue exceeds the field length (fixes #21019)

(cherry picked from commit 99904f1)
  • Loading branch information
jef-n committed Jan 23, 2019
1 parent 3d4c6c4 commit 1b6329c3c03a07e46d9b1c53ccd7bc3b42b3b247
Showing with 9 additions and 8 deletions.
  1. +9 −8 src/gui/qgsfieldvalidator.cpp
@@ -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 )
{

0 comments on commit 1b6329c

Please sign in to comment.
You can’t perform that action at this time.