File indexing completed on 2024-05-12 16:42:16

0001 /*
0002     SPDX-FileCopyrightText: 2014 Christian Dávid <christian-david@web.de>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #include "validators.h"
0007 
0008 #include <QStringList>
0009 
0010 bool validators::checkLineLength(const QString& text, const int& length)
0011 {
0012     const QStringList lines = text.split('\n');
0013     foreach (QString line, lines) {
0014         if (line.length() > length)
0015             return false;
0016     }
0017     return true;
0018 }
0019 
0020 bool validators::checkCharset(const QString& text, const QString& allowedChars)
0021 {
0022     const int length = text.length();
0023     for (int i = 0; i < length; ++i) {
0024         if (!allowedChars.contains(text.at(i)))
0025             return false;
0026     }
0027     return true;
0028 }