File indexing completed on 2024-06-23 05:14:19

0001 /* -*- mode: c++; c-basic-offset:4 -*-
0002     utils/validation.h
0003 
0004     This file is part of Kleopatra, the KDE keymanager
0005     SPDX-FileCopyrightText: 2008 Klarälvdalens Datakonsult AB
0006     SPDX-FileCopyrightText: 2022 g10 Code GmbH
0007     SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de>
0008 
0009     SPDX-License-Identifier: GPL-2.0-or-later
0010 */
0011 
0012 #pragma once
0013 
0014 #include <memory>
0015 
0016 class QString;
0017 class QValidator;
0018 
0019 namespace Kleo
0020 {
0021 namespace Validation
0022 {
0023 
0024 enum Flags {
0025     Optional,
0026     Required,
0027 };
0028 
0029 std::shared_ptr<QValidator> email(Flags flags = Required);
0030 /**
0031  * Creates a validator for the name part of the user ID of an OpenPGP key with
0032  * restrictions that are necessary for usage with the edit-key interface.
0033  */
0034 std::shared_ptr<QValidator> pgpName(Flags flags = Required);
0035 /**
0036  * Creates a validator for the name part of the user ID of an OpenPGP key with
0037  * less restrictions than \ref pgpName.
0038  */
0039 std::shared_ptr<QValidator> simpleName(Flags flags = Required);
0040 
0041 std::shared_ptr<QValidator> email(const QString &additionalRegExp, Flags flags = Required);
0042 /**
0043  * Creates a validator for the name part of the user ID of an OpenPGP key with
0044  * restrictions that are necessary for usage with the edit-key interface, and
0045  * with additional restrictions imposed by \p additionalRegExp.
0046  */
0047 std::shared_ptr<QValidator> pgpName(const QString &additionalRegExp, Flags flags = Required);
0048 /**
0049  * Creates a validator for the name part of the user ID of an OpenPGP key with
0050  * less restrictions than \ref pgpName, but with additional restrictions imposed
0051  * by \p additionalRegExp.
0052  */
0053 std::shared_ptr<QValidator> simpleName(const QString &additionalRegExp, Flags flags = Required);
0054 
0055 }
0056 }