mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 08:36:52 +08:00
Ref T215, validator can be restricted to a string list
This commit is contained in:
@@ -34,6 +34,19 @@ namespace BlackGui
|
||||
if (m_optionalValue && input.isEmpty()) { return Acceptable; }
|
||||
if (input.length() > m_maxLength) { return Invalid; }
|
||||
if (input.length() < m_minLength) { return Intermediate; }
|
||||
if (!m_restrictions.isEmpty())
|
||||
{
|
||||
bool valid = false;
|
||||
for (const QString &r : m_restrictions)
|
||||
{
|
||||
if (r.startsWith(input))
|
||||
{
|
||||
valid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!valid) { return Invalid; }
|
||||
}
|
||||
return Acceptable;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user