Ref T215, validator can be restricted to a string list

This commit is contained in:
Klaus Basan
2018-01-02 02:25:08 +01:00
parent 77cd49cb0f
commit ee0d69faf2
2 changed files with 20 additions and 7 deletions

View File

@@ -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;
}