This is a video about how you can create a password checker using Notion formulas.
Criteria checker formula:
lets(
hasEightChars,
if(prop("Password").length() [greater than]= 8, true, false),
hasUpper,
if(prop("Password") != prop("Password").lower(), true, false),
hasLower,
if(prop("Password") != prop("Password").upper(), true, false),
hasDigit,
lets(
digits,
[0,1,2,3,4,5,6,7,8,9],
digits.map(prop("Password").contains(current.format())).contains(true)
),
hasSpecial,
if(prop("Password").match("[^A-Za-z0-9]").empty().not(), true, false),
hasNoSpaces,
if(prop("Password").contains(" ").not(), true, false),
hasNoCharRep,
prop("Password").split("").map(lets(
currentLetter,
current,
i,
index,
pwLetterList,
prop("Password").split(""),
and(
i [less than] pwLetterList.length() - 2,
currentLetter == pwLetterList.at(i + 1),
currentLetter == pwLetterList.at(i + 2)
)
)).contains(true).not(),
hasNoCommonPatterns,
lets(
commonPatterns,
["abcd", "1234", "qwerty", "password"],
commonPatterns.map(prop("Password").lower().contains(current.lower())).contains(true).not()
),
hasNoUserName,
if(prop("Password").lower().contains(prop("Username").lower()).not(), true, false),
isRetypedPasswordSame,
prop("Re type Password").empty().not() && prop("Re type Password").lower() == prop("Password").lower(),
checkList,
[
[hasEightChars, "Minimum 8 Charecters required"],
[hasUpper, "There should be atleast one upper case letter"],
[hasLower, "There should be atleast one lower case letter"],
[hasDigit, "There should be atleast one digit (0-9)"],
[hasSpecial, "There should be atleast one special char- ! @ # $ % ^ & * ( ) _ +"],
[hasNoSpaces, "The password should not contain spaces"],
[hasNoCharRep, "Any charecter should not be repeated more than three times"],
[hasNoCommonPatterns, "The password contains common patterns"],
[hasNoUserName, "The password should not contain the username"],
[isRetypedPasswordSame, prop("Re type Password").empty() ? "Re typed password is empty" : "The Retyped password should be same as the password"]
],
lets(
checkListValues,
checkList.filter(current.at(0) != true),
if(
checkListValues.empty(),
"The password is strong ✅".style("c","b","green","green_background"),
(checkListValues.length() + " Issues are found:").style("c","b","orange","orange_background") + "\n" + checkListValues.map(
((index + 1) + "." + current.at(1)).style("c","b","orange","orange_background")
).join("\n")
)
)
)
Password Score Formula:
(the formula is too long to be put in the description ~5000+ chars, lol
don't worry, check out the first comment below for the formula, have a good day!)
Информация по комментариям в разработке