Index: sources/view/settings/VSettings.cpp =================================================================== diff -u -rc9f8f8cf3c6c37fc6460d8675c62c9442c4d4263 -rf2656247b7f73e4c2494605af2f7bdbbd26f776f --- sources/view/settings/VSettings.cpp (.../VSettings.cpp) (revision c9f8f8cf3c6c37fc6460d8675c62c9442c4d4263) +++ sources/view/settings/VSettings.cpp (.../VSettings.cpp) (revision f2656247b7f73e4c2494605af2f7bdbbd26f776f) @@ -16,6 +16,7 @@ // Qt #include +#include // Project #include "GuiController.h" @@ -207,3 +208,29 @@ } if ( isChanged ) emit instructionsChanged(_instructions); } + +/*! + * \brief VSettings::isPasswordConforming + * \details Validates the passed string for conforming to the "at least one + * capital letter, at least one digit, at least one symbol" rule + * \param vPassword - the string to check + * \returns true if string pass conforms, false otherwise + */ +bool VSettings::isPasswordConforming(const QString vPassword) { + QRegularExpression passwordStringRegexObject; + + // Check for at least one capitalized letter + passwordStringRegexObject.setPattern("[A-Z]{1,}"); + bool hasCapitalized = passwordStringRegexObject.match(vPassword).hasMatch(); + + // Check for at least one digit + passwordStringRegexObject.setPattern("[0-9]{1,}"); + bool hasNumeric = passwordStringRegexObject.match(vPassword).hasMatch(); + + // Check for at least one special character, defining it as a non-alphanumeric character + passwordStringRegexObject.setPattern("[^A-Za-z0-9]{1,}"); + bool hasSymbol = passwordStringRegexObject.match(vPassword).hasMatch(); + + return hasCapitalized && hasNumeric && hasSymbol; +} +