From 1a51b2917c3e4634ff2e18d3d0fd01b8bace6a58 Mon Sep 17 00:00:00 2001 From: gabriel-logan Date: Wed, 29 May 2024 22:32:33 -0300 Subject: [PATCH] chore: [locale] page working 100% --- .../js/functions/isPort/page.tsx | 2 +- .../js/functions/cnpjIsValid/page.tsx | 89 ++++++ .../js/functions/cpfIsValid/page.tsx | 106 ++++++ .../js/functions/getOnlyEmail/page.tsx | 145 +++++++++ .../js/functions/identifyFlagCard/page.tsx | 84 +++++ .../js/functions/isAscii/page.tsx | 101 ++++++ .../js/functions/isBase64/page.tsx | 93 ++++++ .../documentation/js/functions/isCEP/page.tsx | 86 +++++ .../js/functions/isCreditCardValid/page.tsx | 95 ++++++ .../js/functions/isDate/page.tsx | 82 +++++ .../js/functions/isDecimal/page.tsx | 108 +++++++ .../js/functions/isEmail/page.tsx | 93 ++++++ .../js/functions/isEmpty/page.tsx | 108 +++++++ .../js/functions/isMACAddress/page.tsx | 98 ++++++ .../documentation/js/functions/isMD5/page.tsx | 99 ++++++ .../js/functions/isNumber/page.tsx | 88 +++++ .../js/functions/isPort/page.tsx | 108 +++++++ .../js/functions/isPostalCode/page.tsx | 155 +++++++++ .../js/functions/isTime/page.tsx | 116 +++++++ .../js/functions/isValidAudio/page.tsx | 63 ++++ .../js/functions/isValidImage/page.tsx | 111 +++++++ .../js/functions/isValidPdf/page.tsx | 43 +++ .../js/functions/isValidTxt/page.tsx | 43 +++ .../js/functions/isValidVideo/page.tsx | 65 ++++ .../functions/passwordStrengthTester/page.tsx | 142 +++++++++ .../functions/validateBRPhoneNumber/page.tsx | 105 ++++++ .../js/functions/validateEmail/page.tsx | 253 +++++++++++++++ .../js/functions/validateName/page.tsx | 107 +++++++ .../functions/validatePassportNumber/page.tsx | 110 +++++++ .../js/functions/validatePassword/page.tsx | 291 +++++++++++++++++ .../js/functions/validatePhoneNumber/page.tsx | 80 +++++ .../js/functions/validateSurname/page.tsx | 100 ++++++ .../js/functions/validateTextarea/page.tsx | 123 +++++++ .../functions/validateUSPhoneNumber/page.tsx | 104 ++++++ .../js/functions/validateUsername/page.tsx | 139 ++++++++ .../(doc-session)/documentation/js/layout.tsx | 13 + .../(doc-session)/documentation/js/page.tsx | 301 ++++++++++++++++++ .../MainPageSyntexHightlighter.tsx | 94 ++++++ .../(doc-session)/documentation/page.tsx | 71 +++++ .../(doc-session)/documentation/py/layout.tsx | 13 + .../(doc-session)/documentation/py/page.tsx | 227 +++++++++++++ .../src/app/[locale]/(doc-session)/layout.tsx | 35 ++ docs/src/app/[locale]/about/page.tsx | 42 +++ docs/src/app/[locale]/info/page.tsx | 42 +++ docs/src/app/[locale]/layout.tsx | 56 ++++ docs/src/app/[locale]/page.tsx | 95 ++++++ .../app/[locale]/privacity-polices/page.tsx | 44 +++ docs/src/app/[locale]/terms/page.tsx | 67 ++++ docs/src/app/[locale]/types/locale.ts | 5 + docs/src/app/sitemap.ts | 54 ++++ docs/src/components/Drawer/index.tsx | 4 +- docs/src/components/Footer/index.tsx | 18 +- docs/src/components/Header/index.tsx | 30 +- .../components/Internationalization/index.ts | 6 +- .../components/SidebarWrapper/js/index.tsx | 15 +- docs/src/css/functions.css | 6 +- docs/src/css/functions.css.map | 2 +- docs/src/css/functions.scss | 6 +- docs/src/locales/en/en.json | 10 +- docs/src/locales/pt/pt.json | 14 +- 60 files changed, 4964 insertions(+), 41 deletions(-) create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/functions/cnpjIsValid/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/functions/cpfIsValid/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/functions/getOnlyEmail/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/functions/identifyFlagCard/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/functions/isAscii/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/functions/isBase64/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/functions/isCEP/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/functions/isCreditCardValid/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/functions/isDate/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/functions/isDecimal/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/functions/isEmail/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/functions/isEmpty/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/functions/isMACAddress/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/functions/isMD5/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/functions/isNumber/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/functions/isPort/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/functions/isPostalCode/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/functions/isTime/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/functions/isValidAudio/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/functions/isValidImage/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/functions/isValidPdf/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/functions/isValidTxt/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/functions/isValidVideo/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/functions/passwordStrengthTester/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/functions/validateBRPhoneNumber/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/functions/validateEmail/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/functions/validateName/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/functions/validatePassportNumber/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/functions/validatePassword/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/functions/validatePhoneNumber/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/functions/validateSurname/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/functions/validateTextarea/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/functions/validateUSPhoneNumber/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/functions/validateUsername/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/layout.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/js/subComponents/MainPageSyntexHightlighter.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/py/layout.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/documentation/py/page.tsx create mode 100644 docs/src/app/[locale]/(doc-session)/layout.tsx create mode 100644 docs/src/app/[locale]/about/page.tsx create mode 100644 docs/src/app/[locale]/info/page.tsx create mode 100644 docs/src/app/[locale]/layout.tsx create mode 100644 docs/src/app/[locale]/page.tsx create mode 100644 docs/src/app/[locale]/privacity-polices/page.tsx create mode 100644 docs/src/app/[locale]/terms/page.tsx create mode 100644 docs/src/app/[locale]/types/locale.ts diff --git a/docs/src/app/(doc-session)/documentation/js/functions/isPort/page.tsx b/docs/src/app/(doc-session)/documentation/js/functions/isPort/page.tsx index dd807ce..49f67ec 100644 --- a/docs/src/app/(doc-session)/documentation/js/functions/isPort/page.tsx +++ b/docs/src/app/(doc-session)/documentation/js/functions/isPort/page.tsx @@ -92,7 +92,7 @@ console.log(result6);`}

{t("Notes")}

{t( - "agora esse The function first checks if the input value is either a string or a number. If the value is a string, it is converted to an integer using", + "The function first checks if the input value is either a string or a number. If the value is a string, it is converted to an integer using", )}{" "} parseInt(value, 10).{" "} {t( diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/functions/cnpjIsValid/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/cnpjIsValid/page.tsx new file mode 100644 index 0000000..3fbad44 --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/cnpjIsValid/page.tsx @@ -0,0 +1,89 @@ +import "@/css/functions.css"; + +import { setStaticParamsLocale } from "next-international/server"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import DrawerComponent from "@/components/Drawer"; +import { getScopedI18n } from "@/locales/server"; + +export default async function CnpjIsValid({ + params: { locale }, +}: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationJsFunctions"); + return ( +

+
+ +
+
+

cnpjIsValid {t("Function Documentation")}

+

+ {t("The")} cnpjIsValid{" "} + {t( + "function is used to validate a Brazilian CNPJ (National Registry of Legal Entities) number. It returns an object containing the", + )}{" "} + isValid (boolean) {t("and")} errorMsg{" "} + (string){" "} + {t( + "properties, indicating whether the CNPJ is valid and, in case of an error, the corresponding error message.", + )} +

+ +

Import

+

+ {t( + 'The function can be imported using ES6 syntax from the "multiform-validator" package:', + )} +

+ + + {`import { cnpjIsValid } from 'multiform-validator';`} + + +

{t("Parameters")}

+

{t("The function takes two parameters:")}

+
    +
  • + cnpj (string) - {t("The CNPJ number to be validate.")} +
  • +
  • + errorMsg ({t("optional array")}) -{" "} + {t( + "A list of custom error messages. If not provided, it uses a default list of error messages.", + )} +
  • +
+ +

{t("Examples")}

+ + + {`// Example 1 - Using the CNPJ number '72.501.263/0001-40' const +result1 = cnpjIsValid('72.501.263/0001-40'); +console.log(result1.isValid); // true +console.log(result1.errorMsg); // null + +// Example 2 - Using the CNPJ number '73.506.263/0001-45' and custom error messages +const result2 = cnpjIsValid('73.506.263/0001-45', ['CNPJ is wrong']); +console.log(result2.isValid); // false +console.log(result2.errorMsg); // 'CNPJ is wrong'`} + + +

{t("Notes")}

+

+ {t("If the function is called with an invalid value for the")}{" "} + errorMsg{" "} + {t( + "parameter (non-array), or if an error occurs during the validation process, the function will return an object with", + )}{" "} + isValid {t("set to")} false {t("and")}{" "} + errorMsg{" "} + {t("containing the default error message 'Unknown error'.")} +

+
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/functions/cpfIsValid/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/cpfIsValid/page.tsx new file mode 100644 index 0000000..2a4f209 --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/cpfIsValid/page.tsx @@ -0,0 +1,106 @@ +import "@/css/functions.css"; + +import { setStaticParamsLocale } from "next-international/server"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import DrawerComponent from "@/components/Drawer"; +import { getScopedI18n } from "@/locales/server"; + +export default async function CpfIsValid({ params: { locale } }: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationJsFunctions"); + + return ( +
+
+ +
+
+

cpfIsValid {t("Function Documentation")}

+

+ {t("The")} cpfIsValid{" "} + {t( + "function is used to validate a Brazilian CPF (Individual Taxpayer Identification) number. It returns an object containing the", + )}{" "} + isValid (boolean) {t("and")} errorMsg{" "} + (string){" "} + {t( + "properties, indicating whether the CPF is valid and, in case of an error, the corresponding error message.", + )} +

+ +

Import

+

{t("There are two ways to import the function:")}

+
    +
  • + + {t("Using")} require (Node.js): + +
  • + + {`const { cpfIsValid } = require('multiform-validator');`} + +
  • + + {t("Using")} Import (ES6): + +
  • + + {`import { cpfIsValid } from 'multiform-validator';`} + +
+ +

{t("Parameters")}

+

{t("The function takes two parameters:")}

+
    +
  • + cpf (string) - {t("The CPF number to be validated.")} +
  • +
  • + errorMsg ({t("optional array")}) -{" "} + {t( + "A list of custom error messages. If not provided, it uses a default list of error messages.", + )} +
  • +
+ +

{t("Examples")}

+ + + {`// Example 1 - Using the CPF number '123.456.789.10' +const result1 = cpfIsValid('123.456.789.10'); +console.log(result1.isValid); // false +console.log(result1.errorMsg); // 'CPF invalid' + +// Example 2 - Using the CPF number '12345678910' and custom error messages +const result2 = cpfIsValid("12345678910", [ + "CPF is wrong", + "Must have at least 11 digits", +]); +console.log(result2.isValid); // false +console.log(result2.errorMsg); // 'CPF is wrong' + +// Example 3 - Using a valid CPF number '52998224725' +const result3 = cpfIsValid('52998224725'); +console.log(result3.isValid); // true +console.log(result3.errorMsg); // null`} + + +

{t("Notes")}

+

+ {t("If the function is called with an invalid value for the")}{" "} + errorMsg{" "} + {t( + "parameter (non-array), or if an error occurs during the validation process, the function will return an object with", + )}{" "} + isValid {t("set to")} false {t("and")}{" "} + errorMsg{" "} + {t("containing the default error message 'Unknown error'.")} +

+
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/functions/getOnlyEmail/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/getOnlyEmail/page.tsx new file mode 100644 index 0000000..32c67fa --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/getOnlyEmail/page.tsx @@ -0,0 +1,145 @@ +import "@/css/functions.css"; + +import { setStaticParamsLocale } from "next-international/server"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import DrawerComponent from "@/components/Drawer"; +import { getScopedI18n } from "@/locales/server"; + +export default async function GetOnlyEmail({ + params: { locale }, +}: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationJsFunctions"); + + return ( +
+
+ +
+
+

getOnlyEmail {t("Function Documentation")}

+

+ {t("The")} getOnlyEmail{" "} + {t( + "function extracts email addresses from a given text. If the optional", + )}{" "} + multiple {t("parameter is set to")} true,{" "} + {t( + "it returns an array with all the email addresses found. Otherwise, it returns only the first email address found as a string.", + )} +

+ +

Import

+

+ {t( + 'The function can be imported using ES6 syntax from the "multiform-validator" package:', + )} +

+ + + {`import { getOnlyEmail } from 'multiform-validator';`} + + +

+ {t( + "Alternatively, you can import the function using CommonJS syntax with", + )}{" "} + require (Node.js): +

+ + + {`const { getOnlyEmail } = require('multiform-validator');`} + + +

{t("Parameters")}

+

{t("The function takes two parameters:")}

+
    +
  • + text (string) -{" "} + {t("The input text from which emails will be extracted.")} +
  • +
  • + multiple {t("(optional boolean) - If set to")}{" "} + true,{" "} + {t( + "the function will return an array with all the email addresses found. If set to", + )}{" "} + false{" "} + {t( + "or not provided, it will return only the first email address found as a string.", + )} +
  • +
  • + cleanDomain{" "} + {t( + "(optional boolean | string[]) - Either a boolean value indicating whether to clean after default domains or an array of custom domains to clean after. Default is", + )}{" "} + false{" "} + {t( + "which means it won't clean the email addresses after default domains ['.br', '.io', '.pt', '.us', '.org', '.com'];. If set to", + )}{" "} + true,{" "} + {t( + "it will clean after default domains. If set to an array of strings, it will clean after the specified custom domains.", + )} +
  • +
  • + repeatEmail {t("(optional boolean) - If set to")}{" "} + false,{" "} + {t( + "the function will remove duplicate emails from the output list. If set to", + )}{" "} + true{" "} + {t( + "or not provided, it will keep the duplicate emails in the output list.", + )} +
  • +
+ +

{t("Examples")}

+ + + {`// Example 1 - Extracting multiple emails from the text +const result1 = getOnlyEmail( + "Entre em contato com a equipe: joao@empresa.com, maria@empresa.com, contato@empresa.com", + { multiple: true }, +); +console.log(result1); +// Output: ["joao@empresa.com", "maria@empresa.com", "contato@empresa.com"] + +// Example 2 - Extracting the first email from the text +const result2 = getOnlyEmail( + "Vaga na asdlaod Mande seu email para fiawn@rdwah.com Sim aqui mesmo", +); +console.log(result2); +// Output: "fiawn@rdwah.com" + +const result3 = getOnlyEmail( + "Vaga na asdlaod Mande seu email para fiawn@rdwah.comSim aqui asdasd@gmail.commesmo", + { multiple: true, cleanDomain: true }, +); +console.log(result3); +// Output: [ 'fiawn@rdwah.com', 'asdasd@gmail.com' ] + +const result4 = getOnlyEmail( + "Vaga na asdlaod Mande seu email para fiawn@rdwah.comSim aqui asdasd@gmail.commesmo asdasd asd as fiawn@rdwah.com", + { multiple: true, cleanDomain: true, repeatEmail: true }, +); +console.log(result4); +// Output: [ 'fiawn@rdwah.com', 'asdasd@gmail.com', 'fiawn@rdwah.com' ]`} + + +

{t("Notes")}

+

+ {t( + "If no email address is found in the input text, the function will return the string 'No email found'.", + )} +

+
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/functions/identifyFlagCard/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/identifyFlagCard/page.tsx new file mode 100644 index 0000000..c7cf0e8 --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/identifyFlagCard/page.tsx @@ -0,0 +1,84 @@ +import "@/css/functions.css"; + +import { setStaticParamsLocale } from "next-international/server"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import DrawerComponent from "@/components/Drawer"; +import { getScopedI18n } from "@/locales/server"; + +export default async function IdentifyFlagCard({ + params: { locale }, +}: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationJsFunctions"); + + return ( +
+
+ +
+
+

+ identifyFlagCard {t("Function Documentation")} +

+

+ {t("The")} identifyFlagCard{" "} + {t( + "function is used to identify the credit card flag based on the first digits of the card number. It returns the name of the card flag as a string.", + )} +

+ +

Import

+

+ {t( + 'The function can be imported using ES6 syntax from the "multiform-validator" package:', + )} +

+ + + {`import { identifyFlagCard } from 'multiform-validator';`} + + +

+ {t( + "Alternatively, you can import the function using CommonJS syntax with", + )}{" "} + require (Node.js): +

+ + + {`const { identifyFlagCard } = require('multiform-validator');`} + + +

{t("Parameters")}

+

{t("The function takes one parameter:")}

+
    +
  • + cardNumber (string) -{" "} + {t( + "The credit card number for which to identify the flag based on the first digits.", + )} +
  • +
+ +

{t("Example")}

+ + + {`// Example 1 - Identifying the card flag based on the first digits +const result = identifyFlagCard('6062 8226 8644 9791'); +console.log(result); // Output: "Discover"`} + + +

{t("Notes")}

+

+ {t( + "The function expects the credit card number to be passed as a string. It uses the first digits of the card number to identify the card flag and returns the corresponding flag name as a string. If the card flag cannot be identified or the input is not a string, it returns 'Unknown'.", + )} +

+
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isAscii/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isAscii/page.tsx new file mode 100644 index 0000000..5fa69d1 --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isAscii/page.tsx @@ -0,0 +1,101 @@ +import "@/css/functions.css"; + +import { setStaticParamsLocale } from "next-international/server"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import DrawerComponent from "@/components/Drawer"; +import { getScopedI18n } from "@/locales/server"; + +export default async function IsAscii({ params: { locale } }: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationJsFunctions"); + + return ( +
+
+ +
+
+

isAscii {t("Function Documentation")}

+

+ {t("The")} isAscii{" "} + {t( + "function checks if the input string contains only ASCII characters. It returns", + )}{" "} + true{" "} + {t("if the string is composed of ASCII characters, and")}{" "} + false {t("otherwise.")} +

+ +

Import

+

+ {t( + 'The function can be imported using ES6 syntax from the "multiform-validator" package:', + )} +

+ + + {`import { isAscii } from 'multiform-validator';`} + + +

+ {t( + "Alternatively, you can import the function using CommonJS syntax with", + )}{" "} + require (Node.js): +

+ + + {`const { isAscii } = require('multiform-validator');`} + + +

{t("Parameters")}

+

{t("The function takes one parameter:")}

+
    +
  • + value (string) -{" "} + {t("The input string to check for ASCII characters.")} +
  • +
+ +

{t("Examples")}

+ + + {`// Example 1 - Checking if the string contains only ASCII characters +const result1 = isAscii('Hello'); +console.log(result1); // true + +// Example 2 - Checking a non-ASCII string +const result2 = isAscii('こんにちは'); +console.log(result2); // false + +// Example 3 - Checking a string with only ASCII characters +const result3 = isAscii('12345'); +console.log(result3); // true + +// Example 4 - Checking a null value +const result4 = isAscii(null); +console.log(result4); // false + +// Example 5 - Checking an undefined value +const result5 = isAscii(undefined); +console.log(result5); // false`} + + +

{t("Notes")}

+

+ {t( + "The function expects the input value to be passed as a string. It checks each character of the string, and if any character has a character code greater than 127 (non-ASCII), the function returns", + )}{" "} + false.{" "} + {t( + "If the input is not a string or an empty string, it throws an error.", + )} +

+
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isBase64/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isBase64/page.tsx new file mode 100644 index 0000000..8342d12 --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isBase64/page.tsx @@ -0,0 +1,93 @@ +import "@/css/functions.css"; + +import { setStaticParamsLocale } from "next-international/server"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import DrawerComponent from "@/components/Drawer"; +import { getScopedI18n } from "@/locales/server"; + +export default async function IsBase64({ params: { locale } }: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationJsFunctions"); + + return ( +
+
+ +
+
+

isBase64 {t("Function Documentation")}

+

+ {t("The")} isBase64{" "} + {t( + "function checks if the input string is a valid Base64 string. It returns", + )}{" "} + true {t("if the string is a valid Base64, and")}{" "} + false {t("otherwise.")} +

+ +

Import

+

+ {t( + 'The function can be imported using ES6 syntax from the "multiform-validator" package:', + )} +

+ + + {`import { isBase64 } from 'multiform-validator';`} + + +

+ {t( + "Alternatively, you can import the function using CommonJS syntax with", + )}{" "} + require (Node.js): +

+ + + {`const { isBase64 } = require('multiform-validator');`} + + +

{t("Parameters")}

+

{t("The function takes one parameter:")}

+ +
    +
  • + value (string) -{" "} + {t("The input string to check if it is a valid Base64 string.")} +
  • +
+ +

{t("Examples")}

+ + + {`// Example 1 - Checking if the string is a valid Base64 +const result1 = isBase64('SGVsbG8gV29ybGQh'); +console.log(result1); // true + +// Example 2 - Checking a non-Base64 string +const result2 = isBase64('こんにちは'); +console.log(result2); // false + +// Example 3 - Checking a non-Base64 string with digits +const result3 = isBase64('12345'); +console.log(result3); // false + +// Example 4 - Checking a null value +const result4 = isBase64(null); +console.log(result4); // false`} + + +

{t("Notes")}

+

+ {t( + "The function expects the input value to be passed as a string. It checks if the string is a valid Base64 string using a regular expression. If the input is not a string or an empty string, it throws an error.", + )} +

+
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isCEP/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isCEP/page.tsx new file mode 100644 index 0000000..674d459 --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isCEP/page.tsx @@ -0,0 +1,86 @@ +import "@/css/functions.css"; + +import { setStaticParamsLocale } from "next-international/server"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import DrawerComponent from "@/components/Drawer"; +import { getScopedI18n } from "@/locales/server"; + +export default async function IsCEP({ params: { locale } }: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationJsFunctions"); + + return ( +
+
+ +
+
+

isCEP {t("Function Documentation")}

+

+ {t("The")} isCEP{" "} + {t( + "function checks if the input string is a valid Brazilian ZIP Code (CEP). It returns", + )}{" "} + true {t("if the CEP is valid, and")} false{" "} + {t("otherwise.")} +

+ +

Import

+

+ {t( + 'The function can be imported using ES6 syntax from the "multiform-validator" package:', + )} +

+ + + {`import { isCEP } from 'multiform-validator';`} + + +

+ {t( + "Alternatively, you can import the function using CommonJS syntax with", + )}{" "} + require (Node.js): +

+ + + {`const { isCEP } = require('multiform-validator');`} + + +

{t("Parameters")}

+

{t("The function takes one parameter:")}

+
    +
  • + cep (string) -{" "} + {t( + "The input string to check if it is a valid Brazilian ZIP Code (CEP).", + )} +
  • +
+ +

{t("Examples")}

+ + + {`// Example 1 - Checking if the CEP is valid with dashes +const result1 = isCEP('12345-678'); +console.log(result1); // true + +// Example 2 - Checking if the CEP is valid without dashes +const result2 = isCEP('12345678'); +console.log(result2); // true + +// Example 3 - Checking an invalid CEP with an incorrect format +const result3 = isCEP('12.345-678'); +console.log(result3); // false`} + + +

{t("Notes")}

+

{t("The function expects the input to be passed as a string.")}

+
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isCreditCardValid/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isCreditCardValid/page.tsx new file mode 100644 index 0000000..91552b4 --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isCreditCardValid/page.tsx @@ -0,0 +1,95 @@ +import "@/css/functions.css"; + +import { setStaticParamsLocale } from "next-international/server"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import DrawerComponent from "@/components/Drawer"; +import { getScopedI18n } from "@/locales/server"; + +export default async function IsCreditCard({ + params: { locale }, +}: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationJsFunctions"); + + return ( +
+
+ +
+
+

+ isCreditCardValid {t("Function Documentation")} +

+

+ {t("The")} isCreditCardValid{" "} + {t( + "function checks if the input string represents a valid credit card number using the Luhn algorithm. It returns", + )}{" "} + true {t("if the credit card number is valid, and")}{" "} + false {t("otherwise.")} +

+ +

Import

+

+ {t( + 'The function can be imported using ES6 syntax from the "multiform-validator" package:', + )} +

+ + + {`import { isCreditCardValid } from 'multiform-validator';`} + + +

+ {t( + "Alternatively, you can import the function using CommonJS syntax with", + )}{" "} + require (Node.js): +

+ + + {`const { isCreditCardValid } = require('multiform-validator');`} + + +

{t("Parameters")}

+

{t("The function takes one parameter:")}

+ +
    +
  • + cardNumber (string) -{" "} + {t( + "The input string representing the credit card number to validate.", + )} +
  • +
+ +

{t("Examples")}

+ + + {`// Example 1 - Valid credit card number with spaces +const result1 = isCreditCardValid('6062 8226 8644 9791'); +console.log(result1); // true + +// Example 2 - Valid credit card number without spaces +const result2 = isCreditCardValid('6062822686449791'); +console.log(result2); // true + +// Example 3 - Invalid credit card number (does not pass the Luhn algorithm) +const result3 = isCreditCardValid('1234 5678 9012 3456'); +console.log(result3); // false`} + + +

{t("Notes")}

+

+ {t( + "The function expects the input value to be passed as a string representing a credit card number. It removes any non-digit characters and applies the Luhn algorithm to validate the credit card number. If the input is not a string, the function throws an error.", + )} +

+
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isDate/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isDate/page.tsx new file mode 100644 index 0000000..a611e86 --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isDate/page.tsx @@ -0,0 +1,82 @@ +import "@/css/functions.css"; + +import { setStaticParamsLocale } from "next-international/server"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import DrawerComponent from "@/components/Drawer"; +import { getScopedI18n } from "@/locales/server"; + +export default async function IsDate({ params: { locale } }: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationJsFunctions"); + + return ( +
+
+ +
+
+

isDate {t("Function Documentation")}

+

+ The isDate{" "} + {t("function checks if the input string is a valid date.")} +

+ +

Import

+

+ {t( + 'The function can be imported using ES6 syntax from the "multiform-validator" package:', + )} +

+ + + {`import { isDate } from 'multiform-validator';`} + + +

+ {t( + "Alternatively, you can import the function using CommonJS syntax with", + )}{" "} + require (Node.js): +

+ + + {`const { isDate } = require('multiform-validator');`} + + +

{t("Parameters")}

+

{t("The function takes one parameter:")}

+
    +
  • + value (string) -{" "} + {t("The input string representing the date")} +
  • +
+ +

{t("Examples")}

+ + + {`// Example 1 - Valid date +const result1 = isDate("1999-12-31"); +console.log(result1); // true + +// Example 2 - Valid date +const result2 = isDate("2021-01-01"); +console.log(result2); // true + +// Example 3 - Invalid date +const result3 = isDate("1234 5678 9012 3456"); +console.log(result3); // false`} + + +

{t("Notes")}

+

+ {t("The function expects the input value to be passed as a string.")} +

+
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isDecimal/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isDecimal/page.tsx new file mode 100644 index 0000000..6613f48 --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isDecimal/page.tsx @@ -0,0 +1,108 @@ +import "@/css/functions.css"; + +import { setStaticParamsLocale } from "next-international/server"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import DrawerComponent from "@/components/Drawer"; +import { getScopedI18n } from "@/locales/server"; + +export default async function IsDecimal({ params: { locale } }: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationJsFunctions"); + + return ( +
+
+ +
+
+

isDecimal {t("Function Documentation")}

+

+ {t("The")} isDecimal{" "} + {t( + "function checks if the input string or number represents a valid decimal number. It returns", + )}{" "} + true{" "} + {t( + "if the value is a valid decimal number and follows one of the supported formats, and", + )}{" "} + false {t("otherwise.")} +

+ +

Import

+

+ {t( + 'The function can be imported using ES6 syntax from the "multiform-validator" package:', + )} +

+ + + {`import { isDecimal } from 'multiform-validator';`} + + +

+ {t( + "Alternatively, you can import the function using CommonJS syntax with", + )}{" "} + require (Node.js): +

+ + + {`const { isDecimal } = require('multiform-validator');`} + + +

{t("Parameters")}

+

{t("The function takes one parameter:")}

+ +
    +
  • + value (string|number) -{" "} + {t( + "The input value to check if it represents a valid decimal number.", + )} +
  • +
+ +

{t("Examples")}

+ + + {`// Example 1 - Valid decimal numbers +const result1 = isDecimal('123.45'); +console.log(result1); // true + +const result2 = isDecimal('-123.45'); +console.log(result2); // true + +const result3 = isDecimal('0.123'); +console.log(result3); // true + +const result4 = isDecimal('1,234.56'); +console.log(result4); // true + +// Example 2 - Invalid decimal numbers +const result5 = isDecimal('1.234,56'); +console.log(result5); // false (invalid format) + +const result6 = isDecimal('abc'); +console.log(result6); // false (not a valid number) + +const result7 = isDecimal('12a.34'); +console.log(result7); // false (not a valid number) + +const result8 = isDecimal('12.34.56'); +console.log(result8); // false (not a valid number)`} + + +

{t("Notes")}

+

+ {t( + "The function expects the input value to be passed as a string or a number representing a decimal number. If the input is not a string or number, or an empty string, the function throws an error. It uses a regular expression to validate decimal numbers, supports both dot (.) and comma (,) as decimal separators, and checks for multiple decimal separators. Additionally, it performs checks for the negative sign to ensure it is only at the beginning of the value.", + )} +

+
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isEmail/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isEmail/page.tsx new file mode 100644 index 0000000..ff853cf --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isEmail/page.tsx @@ -0,0 +1,93 @@ +import "@/css/functions.css"; + +import Link from "next/link"; +import { setStaticParamsLocale } from "next-international/server"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import DrawerComponent from "@/components/Drawer"; +import { getScopedI18n } from "@/locales/server"; + +export default async function IsEmail({ params: { locale } }: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationJsFunctions"); + + return ( +
+
+ +
+
+

isEmail {t("Function Documentation")}

+

+ {t("The")} isEmail{" "} + {t( + "function checks if the input string is a valid email address. It returns", + )}{" "} + true{" "} + {t( + "if the email address is valid and follows the supported format, and", + )}{" "} + false {t("otherwise.")} +

+

+ {t( + "This function just checks the syntax of the email to see if it's valid or not, if you need a stronger validation, use: ", + )}{" "} + + validateEmail + +

+

Import

+

+ {t( + 'The function can be imported using ES6 syntax from the "multiform-validator" package:', + )} +

+ + + {`import { isEmail } from 'multiform-validator';`} + + +

+ {t( + "Alternatively, you can import the function using CommonJS syntax with", + )}{" "} + require (Node.js): +

+ + + {`const { isEmail } = require('multiform-validator');`} + + +

{t("Parameters")}

+

{t("The function takes one parameter:")}

+
    +
  • + email (string) -{" "} + {t("The input string representing the email address to validate.")} +
  • +
+ +

{t("Example")}

+ + + {`// Example - Valid email address +const result1 = isEmail('foor@bar.com'); +console.log(result1); // true`} + + +

{t("Notes")}

+

+ {" "} + {t( + "The function expects the input email to be passed as a string. If the input is not a string, it will throw an error. If the email passed is an invalid email, it will return.", + )}{" "} + false. +

+
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isEmpty/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isEmpty/page.tsx new file mode 100644 index 0000000..1d82b1f --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isEmpty/page.tsx @@ -0,0 +1,108 @@ +import "@/css/functions.css"; + +import { setStaticParamsLocale } from "next-international/server"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import DrawerComponent from "@/components/Drawer"; +import { getScopedI18n } from "@/locales/server"; + +export default async function IsEmpty({ params: { locale } }: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationJsFunctions"); + + return ( +
+
+ +
+
+

isEmpty {t("Function Documentation")}

+

+ {t("The")} isEmpty{" "} + {t( + "function checks if the input string is empty or contains only whitespace characters. It returns", + )}{" "} + true{" "} + {t( + "if the input string is empty or consists of only whitespace characters, and", + )}{" "} + false {t("otherwise.")} +

+ +

Import

+

+ {t( + 'The function can be imported using ES6 syntax from the "multiform-validator" package:', + )} +

+ + + {`import { isEmpty } from 'multiform-validator';`} + + +

+ {t( + "Alternatively, you can import the function using CommonJS syntax with", + )}{" "} + require (Node.js): +

+ + + {`const { isEmpty } = require('multiform-validator');`} + + +

{t("Parameters")}

+

{t("The function takes one parameter:")}

+ +
    +
  • + value (string) -{" "} + {t( + "The input string to check if it is empty or contains only whitespace characters.", + )} +
  • +
+ +

{t("Examples")}

+ + + {`// Example 1 - Empty or whitespace strings +const result1 = isEmpty(''); // true +console.log(result1); + +const result2 = isEmpty(' '); // true +console.log(result2); + +// Example 2 - Non-empty strings +const result3 = isEmpty('Hello'); // false +console.log(result3); + +const result4 = isEmpty(' Hello '); // false +console.log(result4); + +// Example 3 - Non-string inputs (will throw an error) +const result5 = isEmpty(null); +console.log(result5); + +const result6 = isEmpty(undefined); +console.log(result6);`} + + +

{t("Notes")}

+

+ {t( + "The function expects the input value to be passed as a string. If the input is not a string, the function throws a TypeError. It removes any leading and trailing whitespace from the input string using the.", + )}{" "} + trim(){" "} + {t( + "method and checks if the resulting string is empty (i.e., has a length of 0). If the input string consists of only whitespace characters, the function also returns.", + )}{" "} + true {t("as it considers such strings to be empty.")} +

+
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isMACAddress/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isMACAddress/page.tsx new file mode 100644 index 0000000..50db840 --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isMACAddress/page.tsx @@ -0,0 +1,98 @@ +import "@/css/functions.css"; + +import { setStaticParamsLocale } from "next-international/server"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import DrawerComponent from "@/components/Drawer"; +import { getScopedI18n } from "@/locales/server"; + +export default async function IsMACAddress({ + params: { locale }, +}: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationJsFunctions"); + + return ( +
+
+ +
+
+

isMACAddress {t("Function Documentation")}

+

+ {t("The")} isMACAddress{" "} + {t( + "function checks if the input string is a valid MAC address. It returns", + )}{" "} + true{" "} + {t( + "if the MAC address is valid and follows the supported formats, and", + )}{" "} + false {t("otherwise.")} +

+ +

Import

+

+ {t( + 'The function can be imported using ES6 syntax from the "multiform-validator" package:', + )} +

+ + + {`import { isMACAddress } from 'multiform-validator';`} + + +

+ {t( + "Alternatively, you can import the function using CommonJS syntax with", + )}{" "} + require (Node.js): +

+ + + {`const { isMACAddress } = require('multiform-validator');`} + + +

{t("Parameters")}

+

{t("The function takes one parameter:")}

+ +
    +
  • + mac (string) -{" "} + {t( + 'The input string representing the MAC address to validate. The MAC address can be in the following formats: "001A2B3C4D5E", "00:1A:2B:3C:4D:5E", or "00-1A-2B-3C-4D-5E".', + )} +
  • +
+ +

{t("Examples")}

+ + + {`// Example 1 - Valid MAC addresses +const result1 = isMACAddress('001A2B3C4D5E'); // true +console.log(result1); + +const result2 = isMACAddress('00:1A:2B:3C:4D:5E'); // true +console.log(result2); + +const result3 = isMACAddress('00-1A-2B-3C-4D-5E'); // true +console.log(result3); + +// Example 2 - Invalid MAC address +const result4 = isMACAddress('Hello'); // false +console.log(result4);`} + + +

{t("Notes")}

+

+ {t( + 'The function expects the input MAC address to be passed as a string. If the input is not a string, the function throws a TypeError. It removes all non-alphanumeric characters from the input string using a regular expression and checks if the resulting string has a valid length (exactly 12 characters). Then, it uses another regular expression to verify if the cleaned MAC address matches the supported pattern. The supported pattern is a 12-character string consisting of hexadecimal digits (0-9, A-F, a-f), with optional separators (":", "-") between pairs of hexadecimal digits.', + )} +

+
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isMD5/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isMD5/page.tsx new file mode 100644 index 0000000..e66f187 --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isMD5/page.tsx @@ -0,0 +1,99 @@ +import "@/css/functions.css"; + +import { setStaticParamsLocale } from "next-international/server"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import DrawerComponent from "@/components/Drawer"; +import { getScopedI18n } from "@/locales/server"; + +export default async function IsMD5({ params: { locale } }: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationJsFunctions"); + + return ( +
+
+ +
+
+

isMD5 {t("Function Documentation")}

+

+ {t("The")} isMD5{" "} + {t( + "function checks if the input string is a valid MD5 hash. It returns", + )}{" "} + true{" "} + {t( + "if the input string is a valid MD5 hash and follows the supported format, and", + )}{" "} + false {t("otherwise.")} +

+ +

Import

+

+ {t( + 'The function can be imported using ES6 syntax from the "multiform-validator" package:', + )} +

+ + + {`import { isMD5 } from 'multiform-validator';`} + + +

+ {t( + "Alternatively, you can import the function using CommonJS syntax with", + )}{" "} + require (Node.js): +

+ + + {`const { isMD5 } = require('multiform-validator');`} + + +

{t("Parameters")}

+

{t("The function takes one parameter:")}

+ +
    +
  • + value (string) -{" "} + {t( + "The input string representing the MD5 hash to validate. The MD5 hash should be a 32-character string consisting of hexadecimal digits (0-9, A-F, a-f).", + )} +
  • +
+ +

{t("Examples")}

+ + + {`// Example 1 - Valid MD5 hashes +const result1 = isMD5('d41d8cd98f00b204e9800998ecf8427e'); // true +console.log(result1); + +const result2 = isMD5('6df23dc03f9b54cc38a0fc1483df6e21'); // true +console.log(result2); + +// Example 2 - Invalid MD5 hashes +const result3 = isMD5('Hello'); // false +console.log(result3); + +const result4 = isMD5('123'); // false +console.log(result4); + +const result5 = isMD5('d41d8cd98f00b204e9800998ecf8427e123'); // false +console.log(result5);`} + + +

{t("Notes")}

+

+ {t( + 'The function expects the input MD5 hash to be passed as a string. If the input is not a string, the function throws a TypeError. It removes leading and trailing whitespace from the input string and checks if the resulting string has a valid length (exactly 32 characters). Then, it uses a regular expression to verify if the cleaned MD5 hash consists only of hexadecimal digits. Additionally, the function checks if the MD5 hash is not a known weak hash, such as "d41d8cd98f00b204e9800998ecf8427e". If any of the checks fail, the function returns false; otherwise, it returns true, indicating that the input string is a valid MD5 hash.', + )} +

+
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isNumber/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isNumber/page.tsx new file mode 100644 index 0000000..a21765e --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isNumber/page.tsx @@ -0,0 +1,88 @@ +import "@/css/functions.css"; + +import { setStaticParamsLocale } from "next-international/server"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import DrawerComponent from "@/components/Drawer"; +import { getScopedI18n } from "@/locales/server"; + +export default async function IsNumber({ params: { locale } }: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationJsFunctions"); + + return ( +
+
+ +
+
+

isNumber {t("Function Documentation")}

+

+ {t("The")} isNumber{" "} + {t( + "function checks if the input value is a valid number. It returns", + )}{" "} + true {t("if the value is a valid number, and")}{" "} + false {t("otherwise.")} +

+ +

Import

+

+ {t( + 'The function can be imported using ES6 syntax from the "multiform-validator" package:', + )} +

+ + + {`import { isNumber } from 'multiform-validator';`} + + +

+ {t( + "Alternatively, you can import the function using CommonJS syntax with", + )}{" "} + require (Node.js): +

+ + + {`const { isNumber } = require('multiform-validator');`} + + +

{t("Parameters")}

+

{t("The function takes one parameter:")}

+
    +
  • + value (any) -{" "} + {t("The value to be checked if it represents a valid number.")} +
  • +
+ +

{t("Examples")}

+ + + {`// Example 1 - Valid numbers +const result1 = isNumber(123); // true +console.log(result1); + +// Example 2 - Not a valid number +const result2 = isNumber('abc'); // false +console.log(result2);`} + + +

{t("Notes")}

+

+ {t( + "The function checks if the input value is not null, undefined, or a boolean type. If any of these conditions are met, the function returns false since these values cannot represent valid numbers. For all other types, the function uses the.", + )}{" "} + parseFloat{" "} + {t( + "function to convert the value to a floating-point number. If the conversion results in a valid number and the value is finite (not infinity or NaN), the function returns true, indicating that the input value is a valid number. Otherwise, it returns false.", + )} +

+
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isPort/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isPort/page.tsx new file mode 100644 index 0000000..34aff10 --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isPort/page.tsx @@ -0,0 +1,108 @@ +import "@/css/functions.css"; + +import { setStaticParamsLocale } from "next-international/server"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import DrawerComponent from "@/components/Drawer"; +import { getScopedI18n } from "@/locales/server"; + +export default async function IsPort({ params: { locale } }: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationJsFunctions"); + + return ( +
+
+ +
+
+

isPort {t("Function Documentation")}

+

+ {t("The")} isPort{" "} + {t( + "function checks if the input value represents a valid port number. It returns", + )}{" "} + true + {t( + "if the value is a valid port number (within the range 1 to 65535), and", + )} + false {t("otherwise.")} +

+ +

Import

+

+ {t( + 'The function can be imported using ES6 syntax from the "multiform-validator" package:', + )} +

+ + + {`import { isPort } from 'multiform-validator';`} + + +

+ {t( + "Alternatively, you can import the function using CommonJS syntax with", + )}{" "} + require (Node.js): +

+ + + {`const { isPort } = require('multiform-validator');`} + + +

{t("Parameters")}

+

+ {t( + "The function takes one parameter that can be either a string or a number: ", + )} +

+
    +
  • + value (string | number) -{" "} + {t("The value to be checked if it represents a valid port number.")} +
  • +
+ +

{t("Examples")}

+ + + {`// Example 1 - Valid port numbers +const result1 = isPort('80'); // true +console.log(result1); + +const result2 = isPort(443); // true +console.log(result2); + +const result3 = isPort('65535'); // true +console.log(result3); + +// Example 2 - Not valid port numbers +const result4 = isPort(0); // false (port number must be greater than 0) +console.log(result4); + +const result5 = isPort('65536'); // false (port number must be less than or equal to 65535) +console.log(result5); + +// Example 3 - Not a valid input value +const result6 = isPort('Hello'); // false (not a valid port number) +console.log(result6);`} + + +

{t("Notes")}

+

+ {t( + "The function first checks if the input value is either a string or a number. If the value is a string, it is converted to an integer using", + )}{" "} + parseInt(value, 10).{" "} + {t( + "If the conversion is successful (resulting in a valid integer), the function checks if the integer is within the valid port range (1 to 65535). If the value is within this range and it is an integer, the function returns true, indicating that the input value represents a valid port number. Otherwise, it returns false.", + )} +

+
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isPostalCode/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isPostalCode/page.tsx new file mode 100644 index 0000000..bd915ab --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isPostalCode/page.tsx @@ -0,0 +1,155 @@ +import "@/css/functions.css"; + +import { setStaticParamsLocale } from "next-international/server"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import DrawerComponent from "@/components/Drawer"; +import { getScopedI18n } from "@/locales/server"; + +export default async function IsPostalCode({ + params: { locale }, +}: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationJsFunctions"); + + return ( +
+
+ +
+
+

isPostalCode {t("Function Documentation")}

+

+ {t("The")} isPostalCode{" "} + {t( + "function checks if the input value represents a valid postal code for supported countries. It returns", + )}{" "} + true{" "} + {t( + "if the value matches the postal code format for any of the supported countries, and", + )}{" "} + false {t("otherwise.")} +

+ +

Import

+

+ {t( + 'The function can be imported using ES6 syntax from the "multiform-validator" package:', + )} +

+ + + {`import { isPostalCode } from 'multiform-validator';`} + + +

+ {t( + "Alternatively, you can import the function using CommonJS syntax with", + )}{" "} + require (Node.js): +

+ + + {`const { isPostalCode } = require('multiform-validator');`} + + +

{t("Parameters")}

+ +

+ {t( + "The function takes one parameter, which must be a string representing the postal code to be checked.", + )} +

+
    +
  • + postalCode (string) -{" "} + {t("The postal code to be checked for validity.")} +
  • +
+ +

{t("Supported Countries")}

+

+ {t("The function supports postal codes for the following countries:")} +

+
    +
  • {t("United States of America")}
  • +
  • {t("Canada")}
  • +
  • {t("United Kingdom")}
  • +
  • {t("France")}
  • +
  • {t("Netherlands")}
  • +
  • {t("Japan")}
  • +
  • {t("Spain")}
  • +
  • {t("South Africa")}
  • +
  • {t("Germany")}
  • +
  • {t("Switzerland")}
  • +
  • {t("Brazil")}
  • +
  • {t("Italy")}
  • +
+ +

{t("Examples")}

+ + + {`// Example 1 - Valid postal codes +const result1 = isPostalCode('12345'); // true (United States) +console.log(result1); + +const result2 = isPostalCode('M4B 1B3'); // true (Canada) +console.log(result2); + +const result3 = isPostalCode('SW1A 1AA'); // true (United Kingdom) +console.log(result3); + +const result4 = isPostalCode('75013'); // true (France) +console.log(result4); + +const result5 = isPostalCode('1012'); // true (Netherlands) +console.log(result5); + +const result6 = isPostalCode('100-0001'); // true (Japan) +console.log(result6); + +// Example 2 - Invalid postal codes +const result7 = isPostalCode('28001'); // true (Spain) +console.log(result7); + +const result8 = isPostalCode('8000'); // true (South Africa) +console.log(result8); + +const result9 = isPostalCode('13355'); // true (Germany) +console.log(result9); + +const result10 = isPostalCode('1002'); // true (Switzerland) +console.log(result10); + +const result11 = isPostalCode('10045-123'); // true (Brazil) +console.log(result11); + +const result12 = isPostalCode('00100'); // true (Italy) +console.log(result12); + +const result13 = isPostalCode('90210'); // true (United States ZIP Code) +console.log(result13); + +// Example 3 - Not a valid postal code +const result14 = isPostalCode('Hello'); // false (not a valid postal code) +console.log(result14);`} + + +

{t("Notes")}

+

+ {t( + "The function uses regular expressions to check the input postal code against supported 'countries' postal code formats. It returns", + )}{" "} + true{" "} + {t( + "if the input value matches any of the supported postal code formats, and", + )}{" "} + false {t("otherwise.")} +

+
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isTime/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isTime/page.tsx new file mode 100644 index 0000000..ddf7d7f --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isTime/page.tsx @@ -0,0 +1,116 @@ +import "@/css/functions.css"; + +import { setStaticParamsLocale } from "next-international/server"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import DrawerComponent from "@/components/Drawer"; +import { getScopedI18n } from "@/locales/server"; + +export default async function IsTime({ params: { locale } }: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationJsFunctions"); + + return ( +
+
+ +
+
+

isTime {t("Function Documentation")}

+

+ {t("The")} isTime{" "} + {t( + 'function checks if the input value represents a valid time in the format "hh:mm" or "hh:mm AM/PM" or "hh:mm:ss" or "hh:mm:ss AM/PM". It returns', + )}{" "} + true{" "} + {t("if the value matches any of these formats, and")}{" "} + false {t("otherwise.")} +

+ +

Import

+

+ {t( + 'The function can be imported using ES6 syntax from the "multiform-validator" package:', + )} +

+ + + {`import { isPostalCode } from 'multiform-validator';`} + + +

+ {t( + "Alternatively, you can import the function using CommonJS syntax with", + )}{" "} + require (Node.js): +

+ + + {`const { isPostalCode } = require('multiform-validator');`} + + +

{t("Parameters")}

+ +

+ {t( + "The function takes one parameter, which must be a string representing the time to be checked.", + )} +

+
    +
  • + time (string) -{" "} + {t( + 'The time to be checked for validity. It must be in one of the supported formats: "hh:mm", "hh:mm AM/PM", "hh:mm:ss", or "hh:mm:ss AM/PM".', + )} +
  • +
+ +

{t("Examples")}

+ + + {`// Example 1 - Valid time formats +const result1 = isTime('12:34'); // true +console.log(result1); + +const result2 = isTime('12:34 AM'); // true +console.log(result2); + +const result3 = isTime('23:59:59'); // true +console.log(result3); + +const result4 = isTime('12:34:56 PM'); // true +console.log(result4); + +const result5 = isTime('12:34:56 AM'); // true +console.log(result5); + +// Example 2 - Invalid time formats +const result6 = isTime('12:34:56XM'); // false (invalid format) +console.log(result6); + +const result7 = isTime('25:00'); // false (invalid hour) +console.log(result7); + +const result8 = isTime('23:60'); // false (invalid minute) +console.log(result8); + +const result9 = isTime('23:59:61'); // false (invalid second) +console.log(result9);`} + + +

{t("Notes")}

+

+ {t( + "The function uses a regular expression to check if the input time string matches any of the supported time formats. It returns", + )}{" "} + true{" "} + {t("if the input value matches any of the supported formats, and")}{" "} + false {t("otherwise.")} +

+
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isValidAudio/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isValidAudio/page.tsx new file mode 100644 index 0000000..ba9c94d --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isValidAudio/page.tsx @@ -0,0 +1,63 @@ +import "@/css/functions.css"; + +import { setStaticParamsLocale } from "next-international/server"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import DrawerComponent from "@/components/Drawer"; +import { getScopedI18n } from "@/locales/server"; + +export default async function IsValidAudio({ + params: { locale }, +}: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationJsFunctions"); + + return ( +
+
+ +
+
+

{t("How to use the isValidAudio function")}

+

+ {t("The")} isValidAudio{" "} + {t( + "function is used to check whether an audio file is valid or not. It accepts a Buffer as an argument.", + )} +

+ +

{t("Types that are validated")}

+ +
    +
  • mp3
  • +
  • wav
  • +
+ +

+ {t( + "You can also pass an options object as a second argument to exclude a specific type.", + )} +

+ + + {`import { isValidAudio } from 'multiform-validator'; +import AudioBuffer from 'audio-buffer'; +import AudioBuffer2 from 'audio-buffer2'; + +const buffer: Buffer = AudioBuffer; +const isValid = isValidAudio(buffer); + +console.log(isValid); // true if the audio is valid, false otherwise + +const buffer2: Buffer = AudioBuffer2; +const isValid2 = isValidAudio(buffer2, { exclude: ['wav'] }); + +console.log(isValid2); // true if the audio is valid, false otherwise`} + +
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isValidImage/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isValidImage/page.tsx new file mode 100644 index 0000000..f917653 --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isValidImage/page.tsx @@ -0,0 +1,111 @@ +import "@/css/functions.css"; + +import { setStaticParamsLocale } from "next-international/server"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import DrawerComponent from "@/components/Drawer"; +import { getScopedI18n } from "@/locales/server"; + +export default async function IsValidImage({ + params: { locale }, +}: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationJsFunctions"); + + return ( +
+
+ +
+
+

{t("How to use the isValidImage function")}

+

+ {t("The")} isValidImage{" "} + {t( + "function is used to check whether an image file is valid or not. It accepts a Buffer as an argument.", + )} +

+ +

{t("Types that are validated")}

+ +
    +
  • jpeg
  • +
  • png
  • +
  • gif
  • +
  • ico
  • +
+ +

+ {t( + "You can also pass an options object as a second argument to exclude a specific type.", + )} +

+ + + {`import { isValidImage } from 'multiform-validator'; +import ImageBuffer from 'image-buffer'; + +const buffer: Buffer = ImageBuffer; +const isValid = isValidImage(buffer); + +console.log(isValid); // true if the image is valid, false otherwise`} + + +

+ {t("Passing options to the")} isValidImage +

+ + + {`import { isValidImage } from 'multiform-validator'; +import ImageBuffer from 'image-buffer'; + +const buffer: Buffer = ImageBuffer; +const isValid = isValidImage(buffer, { exclude: ['gif'] }); + +console.log(isValid); // true if the image is valid, false otherwise`} + + +

{t("Example Usage with Nestjs and Multer")}

+

+ {t( + "In this example it only allocates 4 bytes for performance reasons, but you can pass the entire file.", + )} +

+ + + {`const filePath = resolve(process.cwd(), 'public', 'assets', 'images'); + +const fileGetted = resolve(filePath, filename); + +const buffer = Buffer.alloc(4); + +const fd = fs.openSync(fileGetted, 'r'); +fs.readSync(fd, buffer, 0, 4, 0); +fs.closeSync(fd); + +const isValidImageResult = isValidImage(buffer); + +if (!isValidImageResult) { + fs.unlinkSync(fileGetted); + throw new BadRequestException('Invalid image'); +}`} + +

+ {t("First, import the")} isValidImage{" "} + {t( + "function from 'multiform-validator'. Then, define the path to the image you want to check. Call the", + )}{" "} + isValidImage{" "} + {t( + "function with the image path as an argument. The function will return", + )}{" "} + true {t("if the image is valid and")} false{" "} + {t("if it is not.")} +

+
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isValidPdf/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isValidPdf/page.tsx new file mode 100644 index 0000000..080c48a --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isValidPdf/page.tsx @@ -0,0 +1,43 @@ +import "@/css/functions.css"; + +import { setStaticParamsLocale } from "next-international/server"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import DrawerComponent from "@/components/Drawer"; +import { getScopedI18n } from "@/locales/server"; + +export default async function IsValidPdf({ params: { locale } }: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationJsFunctions"); + + return ( +
+
+ +
+
+

{t("How to use the isValidPdf function")}

+ +

+ {t("The")} isValidPdf{" "} + {t( + "function is used to check whether an pdf file is valid or not. It accepts a Buffer as an argument.", + )} +

+ + + {`import { isValidPdf } from 'multiform-validator'; +import PdfBuffer from 'pdf-buffer'; + +const buffer: Buffer = PdfBuffer; +const isValid = isValidPdf(buffer); + +console.log(isValid); // true if the pdf is valid, false otherwise`} + +
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isValidTxt/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isValidTxt/page.tsx new file mode 100644 index 0000000..1ecfc22 --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isValidTxt/page.tsx @@ -0,0 +1,43 @@ +import "@/css/functions.css"; + +import { setStaticParamsLocale } from "next-international/server"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import DrawerComponent from "@/components/Drawer"; +import { getScopedI18n } from "@/locales/server"; + +export default async function IsValidTxt({ params: { locale } }: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationJsFunctions"); + + return ( +
+
+ +
+
+

{t("How to use the isValidTxt function")}

+ +

+ {t("The")} isValidTxt{" "} + {t( + "function is used to check whether an txt file is valid or not. It accepts a Buffer as an argument.", + )} +

+ + + {`import { isValidTxt } from 'multiform-validator'; +import TxtBuffer from 'txt-buffer'; + +const buffer: Buffer = TxtBuffer; +const isValid = isValidTxt(buffer); + +console.log(isValid); // true if the txt is valid, false otherwise`} + +
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isValidVideo/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isValidVideo/page.tsx new file mode 100644 index 0000000..20a9bcc --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/isValidVideo/page.tsx @@ -0,0 +1,65 @@ +import "@/css/functions.css"; + +import { setStaticParamsLocale } from "next-international/server"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import DrawerComponent from "@/components/Drawer"; +import { getScopedI18n } from "@/locales/server"; + +export default async function IsValidVideo({ + params: { locale }, +}: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationJsFunctions"); + + return ( +
+
+ +
+
+

{t("How to use the isValidVideo function")}

+ +

+ {t("The")} isValidVideo{" "} + {t( + "function is used to check whether an video file is valid or not. It accepts a Buffer as an argument.", + )} +

+ +

{t("Types that are validated")}

+ +
    +
  • mkv
  • +
  • mov
  • +
  • mp4
  • +
+ +

+ {t( + "You can also pass an options object as a second argument to exclude a specific type.", + )} +

+ + + {`import { isValidVideo } from 'multiform-validator'; +import VideoBuffer from 'video-buffer'; +import VideoBuffer2 from 'video-buffer2'; + +const buffer: Buffer = VideoBuffer; +const isValid = isValidVideo(buffer); + +console.log(isValid); // true if the video is valid, false otherwise + +const buffer2: Buffer = VideoBuffer2; +const isValid2 = isValidVideo(buffer2, { exclude: ['mov'] }); + +console.log(isValid2); // true if the video is valid, false otherwise`} + +
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/functions/passwordStrengthTester/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/passwordStrengthTester/page.tsx new file mode 100644 index 0000000..5011915 --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/passwordStrengthTester/page.tsx @@ -0,0 +1,142 @@ +import "@/css/functions.css"; + +import { setStaticParamsLocale } from "next-international/server"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import DrawerComponent from "@/components/Drawer"; +import { getScopedI18n } from "@/locales/server"; + +export default async function PasswordStrengthTester({ + params: { locale }, +}: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationJsFunctions"); + + return ( +
+
+ +
+
+

+ Password Strength Tester {t("Function Documentation")} +

+

+ {t("The")} passwordStrengthTester{" "} + {t( + 'function evaluates the strength of a given password and returns the type of password strength as a string. The possible strength types are: "veryWeak", "weak", "regular", "strong", or "veryStrong", based on specific criteria.', + )} +

+ +

Import

+

+ {t( + 'The function can be imported using ES6 syntax from the "password-strength-tester" package:', + )} +

+ + + {`import { passwordStrengthTester } from 'multiform-validator';`} + + +

+ {t( + "Alternatively, you can import the function using CommonJS syntax with", + )}{" "} + require (Node.js): +

+ + + {`const { passwordStrengthTester } = require('multiform-validator');`} + + +

{t("Parameters")}

+

+ {t( + "The function takes one parameter, which must be a string representing the password to be evaluated.", + )} +

+
    +
  • + password (string) -{" "} + {t("The password to be evaluated for strength.")} +
  • +
+ +

{t("Examples")}

+ + + {`const result1 = passwordStrengthTester("12345"); +console.log(result1); // Output: veryWeak + +const result2 = passwordStrengthTester("abcdef"); +console.log(result2); // Output: weak + +const result3 = passwordStrengthTester("abc12345"); +console.log(result3); // Output: regular + +const result4 = passwordStrengthTester("Abc123awdasd"); +console.log(result4); // Output: strong + +const result5 = passwordStrengthTester("SuperSecurePassword123!@"); +console.log(result5); // Output: veryStrong`} + + +

{t("Notes")}

+

+ {t( + "The function checks the length of the password and applies certain criteria to classify the password strength. The returned strength type is based on the following criteria:", + )} +

+
    +
  • + {t( + "'veryWeak' - Password with less than 6 characters, consisting only of numbers", + )} +
  • +
  • + {t( + "'weak' - Password with less than 6 characters, consisting of numbers and letters", + )} +
  • +
  • + {t( + "'weak' - Password that repeats the same character more than 3 times in a row and is less than 10 characters long", + )} +
  • +
  • + {t( + "'weak' - Password between 5 and 8 characters, consisting only of numbers", + )} +
  • +
  • {t("'regular' - Password between 9 and 12 characters")}
  • +
  • + {t( + "'regular' - Password greater than or equal to 6 and less than 8 characters, containing at least one number and one letter", + )} +
  • +
  • + {t( + "'regular' - Password greater than 10 and has characters that are repeated more than 5 times in sequence", + )} +
  • +
  • {t("'strong' - Password between 13 and 16 characters")}
  • +
  • + {t( + "'strong' - Password with 8 or more characters, containing at least one uppercase letter, one number and one lowercase letter", + )} +
  • +
  • {t("'veryStrong' - Password longer than 16 characters")}
  • +
  • + {t( + "'veryStrong' - Password with 8 or more characters, containing at least one uppercase letter, one number, one special character and one lowercase letter", + )} +
  • +
+
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/functions/validateBRPhoneNumber/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/validateBRPhoneNumber/page.tsx new file mode 100644 index 0000000..4fad18a --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/validateBRPhoneNumber/page.tsx @@ -0,0 +1,105 @@ +import "@/css/functions.css"; + +import { setStaticParamsLocale } from "next-international/server"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import DrawerComponent from "@/components/Drawer"; +import { getScopedI18n } from "@/locales/server"; + +export default async function ValidateBRPhoneNumber({ + params: { locale }, +}: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationJsFunctions"); + + return ( +
+
+ +
+
+

+ BR Phone Number Validation {t("Function Documentation")} +

+

+ {t("The")} validateBRPhoneNumber{" "} + {t( + 'function is used to validate Brazilian phone numbers. It returns an object with two properties: "isValid" (boolean) and "errorMsg" (string). The "errorMsg" property will contain the error message if the phone number is invalid, or it will be null if the phone number is valid.', + )} +

+ +

Import

+

+ {t( + 'The function can be imported using ES6 syntax from the "validateBRPhoneNumber" package:', + )} +

+ + + {`import { validateBRPhoneNumber } from 'multiform-validator';`} + + +

+ {t( + "Alternatively, you can import the function using CommonJS syntax with", + )}{" "} + require (Node.js): +

+ + + {`const { validateBRPhoneNumber } = require('multiform-validator');`} + + +

{t("Parameters")}

+

{t("The function takes two parameters:")}

+
    +
  • + phoneNumber (string) -{" "} + {t("The Brazilian phone number to be validated.")} +
  • +
  • + errorMsg (string[]){" "} + {t( + "[optional] - An array of error messages to customize the response. If not provided, the function will use default error messages.", + )} +
  • +
+ +

{t("Default Error Messages")}

+

{t("The default error messages are as follows:")}

+ + + {`[ + 'Invalid value passed', + 'Invalid phone number', + 'Unknown error' +]`} + + +

{t("Examples")}

+ + + {`const result1 = validateBRPhoneNumber('(11) 98765-4321'); +console.log(result1); +// Output: { isValid: true, errorMsg: null } + +const customErrorMsg = ['Invalid format', 'Invalid phone number', 'Unknown error']; +const result2 = validateBRPhoneNumber('(11) 98765-4321', customErrorMsg); +console.log(result2); +// Output: { isValid: true, errorMsg: null } + +const result3 = validateBRPhoneNumber('invalid'); +console.log(result3); +// Output: { isValid: false, errorMsg: 'Invalid value passed' } + +const result4 = validateBRPhoneNumber('(11) 1234-5678', customErrorMsg); +console.log(result4); +// Output: { isValid: false, errorMsg: 'Invalid phone number' }`} + +
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/functions/validateEmail/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/validateEmail/page.tsx new file mode 100644 index 0000000..b702ce4 --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/validateEmail/page.tsx @@ -0,0 +1,253 @@ +import "@/css/functions.css"; + +import { setStaticParamsLocale } from "next-international/server"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import DrawerComponent from "@/components/Drawer"; +import { getScopedI18n } from "@/locales/server"; + +export default async function ValidateEmail({ + params: { locale }, +}: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationJsFunctions"); + + return ( +
+
+ +
+
+

+ Email Validation {t("Function Documentation")} +

+

+ {t("The")} validateEmail{" "} + {t( + 'function is used to validate email addresses. It returns an object with two properties: "isValid" (boolean) and "errorMsg" (string). The "errorMsg" property will contain the error message if the email address is invalid, or it will be null if the email address is valid.', + )} +

+ +

+ {t("What is the difference between")} validateEmail{" "} + {t("and")} isEmail ?{" "} + {t( + "isEmail just does simple validations like checking if the string has the formatting of an email like several validators out there,", + )}{" "} + validateEmail{" "} + {t( + "does not, it does complex validations and better than that, you can customize the validations passing the information in the parameters.", + )} +

+ +

Import

+

+ {t( + 'The function can be imported using ES6 syntax from the "multiform-validator" package:', + )} +

+ + {`import { validateEmail } from "multiform-validator";`} + + +

+ {t( + "Alternatively, you can import the function using CommonJS syntax with", + )}{" "} + require (Node.js): +

+ + + {`const { validateEmail } = require("multiform-validator");`} + + +

{t("Function Signature")}

+ + {`interface OptionsParams { + maxLength?: number; + country?: string; + errorMsg?: (string | null)[]; + validDomains?: boolean | string[]; +} + +const defaultOptionsParams: OptionsParams = { + maxLength: 400, + country: "", + errorMsg: defaultErrorMsg, + validDomains: false, +}; + +function validateEmail( + email: string, + { + maxLength, + country, + errorMsg, + validDomains, + }: OptionsParams = defaultOptionsParams, +): { isValid: boolean, errorMsg: string | null };`} + + +

{t("Parameters")}

+
    +
  • + email (string) -{" "} + {t("The email address to be validated.")} +
  • +
  • + maxLength (number){" "} + {t( + "[optional] - The maximum length allowed for the email address. If not provided, the default value is 400.", + )} +
  • +
  • + country (string){" "} + {t( + "[optional] - The country code to check if the email ends with it. If not provided, no country code check will be performed.", + )} +
  • +
  • + errorMsg (string[]){" "} + {t( + "[optional] - An array of error messages to customize the response. If not provided, the function will use default error messages.", + )} +
  • +
  • + validDomains (boolean | string[]){" "} + {t( + "[optional] - This parameter determines whether to check for specific valid email domains or not. If set to", + )}{" "} + true,{" "} + {t( + "the function will use a default list of valid domains. If set to", + )}{" "} + false,{" "} + {t( + "no domain check will be performed. Alternatively, you can pass an array of custom valid domains to perform the check against a specific list.", + )} +
  • +
+ +

{t("Default list of valid domains")}

+ + {`[ + '@gmail.com', + '@outlook.com', + '@yahoo.com', + '@icloud.com', + '@hotmail.com', + '@mail.ru', + '@yandex.ru', + '@gmx.com', + '@zoho.com', + '@protonmail.com', + '@protonmail.ch' +];`} + + +

{t("Default Error Messages")}

+ + {`[ + 'Invalid value passed', + 'This e-mail is not valid', + 'Email too big, try again', + 'This email is not valid in the country', + 'Email domain is not allowed.', + 'Unknown error', +]`} + + +

{t("Examples")}

+ + {`const result1: ValidateFunctions = validateEmail("foor@bar.com", { + maxLength: 30, + country: "us", +}); +console.log(result1); +// Output: { isValid: false, errorMsg: 'This email is not valid in the country' } + +const customErrorMsg: string[] = [ + "Invalid format", + "Invalid phone number", + "Unknown error", +]; +const result2: ValidateFunctions = validateEmail("foor@bar.com", { + maxLength: 30, + country: "br", + errorMsg: customErrorMsg, +}); +console.log(result2); +// Output: { isValid: false, errorMsg: 'This email is not valid in the country' } + +const result3: ValidateFunctions = validateEmail("invalid", { + maxLength: 30, + errorMsg: ["My own error message"], +}); +console.log(result3); +// Output: { isValid: false, errorMsg: 'This e-mail is not valid' } + +const result4: ValidateFunctions = validateEmail("joao@myOwnDomain.com", { + validDomains: ["@myOwnDomain.com"], +}); +console.log(result4); +// Output: { isValid: true, errorMsg: null } + +const result5: ValidateFunctions = validateEmail("joaoaoao@gmail.com.com", { + validDomains: true, +}); +console.log(result5); +// Output: { isValid: true, errorMsg: null } + +const result6: ValidateFunctions = validateEmail("foo@bar.com", { + maxLength: 25, + validDomains: true, +}); +console.log(result6); +// Output: { isValid: false, errorMsg: 'Email domain is not allowed.' } + +const result7: ValidateFunctions = validateEmail("foo@gmail.com", { + maxLength: 25, + validDomains: ["@myownemail.com"], +}); +console.log(result7); +// Output: { isValid: false, errorMsg: 'Email domain is not allowed.' } + +const result8: ValidateFunctions = validateEmail("foo@gmail.com", { + maxLength: 25, + errorMsg: [null, null, null, null, "This is my own error for domain"], + validDomains: ["@myownemail.com"], +}); +console.log(result8); +// Output: { isValid: false, errorMsg: 'This is my own error for domain' } + +const result9: ValidateFunctions = validateEmail("foo@myownemail.com", { + maxLength: 25, + errorMsg: [null, null, null, null, "This is my own error for domain"], + validDomains: ["@myownemail.com"], +}); +console.log(result9); +// Output: { isValid: true, errorMsg: null } + +const result10: ValidateFunctions = validateEmail("foo@gmail.com", { + maxLength: 25, + errorMsg: ["OwnError1", "OwnError2", "OwnError3", "OwnError4", "OwnError5"], + validDomains: ["@myownemail.com"], +}); +console.log(result10); +// Output: { isValid: false, errorMsg: 'OwnError5' } + +const result11: ValidateFunctions = validateEmail("foo@myownemail.com", { + maxLength: 25, + errorMsg: ["OwnError1", "OwnError2", "OwnError3", "OwnError4", "OwnError5"], + validDomains: ["@myownemail.com"], +}); +console.log(result11); +// Output: { isValid: true, errorMsg: null }`} + +
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/functions/validateName/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/validateName/page.tsx new file mode 100644 index 0000000..a57a359 --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/validateName/page.tsx @@ -0,0 +1,107 @@ +import "@/css/functions.css"; + +import { setStaticParamsLocale } from "next-international/server"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import DrawerComponent from "@/components/Drawer"; +import { getScopedI18n } from "@/locales/server"; + +export default async function ValidateName({ + params: { locale }, +}: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationJsFunctions"); + + return ( +
+
+ +
+
+

Name Validation {t("Function Documentation")}

+

+ {t("The")} validateName{" "} + {t( + "Function is used to validate names. It returns an object with two properties: 'isValid' (boolean) and 'errorMsg' (string). The 'errorMsg' property will contain the error message if the name is invalid, or it will be null if the name is valid.", + )} +

+ +

{t("Function Signature")}

+ + {`function validateName( + name: string, + { + minLength?: number, + maxLength?: number, + errorMsg?: string[] + } +): { isValid: boolean, errorMsg: string | null };`} + + +

{t("Parameters")}

+
    +
  • + name (string) - {t("The name to be validated.")} +
  • +
  • + minLength (number) -{" "} + {t( + "[optional] The minimum length allowed for the name. Default value: 1.", + )} +
  • +
  • + maxLength (number) -{" "} + {t( + "[optional] The maximum length allowed for the name. Default value: 20.", + )} +
  • +
  • + errorMsg (string[]) -{" "} + {t( + "[optional] - An array of error messages to customize the response. If not provided, the function will use default error messages.", + )} +
  • +
+ +

{t("Default Error Messages")}

+ + + {`[ + 'Invalid value passed', + 'Name cannot contain numbers', + 'Name cannot contain special characters', + 'This name is not valid', + 'Name too big, try again', + 'Unknown error', +]`} + + +

{t("Examples")}

+ + + {`const result1 = validateName("John", { + minLength: 2, + maxLength: 20, +}); +console.log(result1); +// Output: { isValid: true, errorMsg: null } + +const result2 = validateName("J0hn"); +console.log(result2); +// Output: { isValid: false, errorMsg: 'Name cannot contain numbers' } + +const result3 = validateName("John$"); +console.log(result3); +// Output: { isValid: false, errorMsg: 'Name cannot contain special characters' } + +const result4 = validateName("NameWithTwentyOneCharacters"); +console.log(result4); +// Output: { isValid: false, errorMsg: 'Name too big, try again' }`} + +
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/functions/validatePassportNumber/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/validatePassportNumber/page.tsx new file mode 100644 index 0000000..33a948d --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/validatePassportNumber/page.tsx @@ -0,0 +1,110 @@ +import "@/css/functions.css"; + +import { setStaticParamsLocale } from "next-international/server"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import DrawerComponent from "@/components/Drawer"; +import { getScopedI18n } from "@/locales/server"; + +export default async function ValidatePassportNumber({ + params: { locale }, +}: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationJsFunctions"); + + return ( +
+
+ +
+
+

+ Passport Number Validation {t("Function Documentation")} +

+

+ {t("The")} validatePassportNumber{" "} + {t( + "function is used to validate passport numbers. It returns an object with two properties: 'isValid' (boolean) and 'country' (string). The 'isValid' property will be true if the passport number matches the supported formats, and 'country' property will indicate the country associated with the passport number. If the passport number does not match any supported format, 'isValid' will be false, and 'country' will be null.", + )} +

+ +

{t("Function Signature")}

+ + + {`function validatePassportNumber( + passportNumber: string +): { isValid: boolean, country: string | null };`} + + +

{t("Parameters")}

+
    +
  • + passportNumber (string) -{" "} + {t("The passport number to be validated.")} +
  • +
+ +

{t("Examples")}

+ + + {`const result1 = validatePassportNumber('A1234567'); +console.log(result1); +// Output: { isValid: true, country: 'United States' } + +const result2 = validatePassportNumber('123456789'); +console.log(result2); +// Output: { isValid: false, country: null }`} + + +

{t("Supported Passport Formats")}

+
    +
  • {t("United States: 9 digits (e.g., '123456789')")}
  • +
  • + {t( + "United Kingdom: 2 uppercase letters followed by 6 digits (e.g., 'AB123456')", + )} +
  • +
  • + {t( + "Germany: 2 uppercase letters followed by 8 digits (e.g., 'AB12345678')", + )} +
  • +
  • + {t( + "Canada: 1 uppercase letter followed by 7 digits (e.g., 'A1234567')", + )} +
  • +
  • + {t( + "Australia: 1 uppercase letter followed by 7 digits (e.g., 'A1234567')", + )} +
  • +
  • {t("Brazil: 9 digits (e.g., '123456789')")}
  • +
  • + {t( + "France: 2 uppercase letters followed by 7 digits (e.g., 'AB1234567')", + )} +
  • +
  • + {t( + "Italy: 1 uppercase letter followed by 7 digits (e.g., 'A1234567')", + )} +
  • +
  • + {t( + "India: 1 uppercase letter followed by 7 digits (e.g., 'A1234567')", + )} +
  • +
  • + {t( + "China: 1 uppercase letter followed by 8 digits (e.g., 'A12345678')", + )} +
  • +
+
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/functions/validatePassword/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/validatePassword/page.tsx new file mode 100644 index 0000000..c64f0d1 --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/validatePassword/page.tsx @@ -0,0 +1,291 @@ +import "@/css/functions.css"; + +import { setStaticParamsLocale } from "next-international/server"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import DrawerComponent from "@/components/Drawer"; +import { getScopedI18n } from "@/locales/server"; + +export default async function ValidatePassword({ + params: { locale }, +}: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationJsFunctions"); + + return ( +
+
+ +
+
+

+ Password Validation {t("Function Documentation")} +

+

+ {t("The")} validatePassword{" "} + {t( + 'function is used to validate passwords. It returns an object with two properties: "isValid" (boolean) and "errorMsg" (string). The "isValid" property will be true if the password meets the specified criteria, and "errorMsg" will contain the error message if the password is invalid, or it will be null if the password is valid.', + )} +

+ +

Import

+

+ {t( + 'The function can be imported using ES6 syntax from the "multiform-validator" package:', + )} +

+ + {`import { validatePassword } from 'multiform-validator';`} + + +

+ {t( + "Alternatively, you can import the function using CommonJS syntax with", + )}{" "} + require (Node.js): +

+ + + {`const { validatePassword } = require('multiform-validator');`} + + +

{t("Function Signature")}

+ + {`interface Options { + requireUppercase?: boolean; + requireSpecialChar?: boolean; + requireNumber?: boolean; + requireString?: boolean; +} + +interface OptionsParams { + minLength?: number; + maxLength?: number; + options?: Options; + errorMsg?: (string | null)[]; +} + +const defaultOptionsParams: OptionsParams = { + minLength: 1, + maxLength: infinity, + options: { + requireUppercase: false, + requireSpecialChar: false, + requireNumber: false, + requireString: false, + }, + errorMsg: defaultErrorMsg, +}; + +function validatePassword( + password: string, + { + minLength, + maxLength, + options, + errorMsg, + }: OptionsParams = defaultOptionsParams, +): { isValid: boolean, errorMsg: string | null };`} + + +

{t("Parameters")}

+
    +
  • + password (string) -{" "} + {t("The password to be validated.")} +
  • +
  • + minLength (number) {t("[optional]")} -{" "} + {t( + "The minimum length allowed for the password. Default value: 1.", + )} +
  • +
  • + maxLength (number) {t("[optional]")} -{" "} + {t( + "The maximum length allowed for the password. Default value: Infinity.", + )} +
  • +
  • + options (object){" "} + {t( + "[optional] - An object with the following optional properties:", + )} +
      +
    • + requireUppercase (boolean) -{" "} + {t( + "Whether the password requires at least one uppercase letter. Default value: false.", + )} +
    • +
    • + requireSpecialChar (boolean) -{" "} + {t( + "Whether the password requires at least one special character", + )}{" "} + {`(e.g., !@#$%^&*(),.?":{}| + <>)`} + . {t("Default value: false.")} +
    • +
    • + requireNumber (boolean) -{" "} + {t( + "Whether the password requires at least one number. Default value: false.", + )} +
    • +
    • + requireString (boolean) -{" "} + {t( + "Whether the password requires at least one letter. Default value: false.", + )} +
    • +
    +
  • +
  • + errorMsg (string[]){" "} + {t( + "[optional] - An array of error messages to customize the response. If not provided, the function will use default error messages.", + )} +
  • +
+ +

{t("Default Error Messages")}

+ + {`[ + 'This password is too long', + 'Password too short', + 'Requires at least one capital letter', + 'Requires at least one special character', + 'Requires at least one number', + 'Requires at least one letter', + 'Unknown error', +]`} + + +

{t("Examples")}

+ + {`const defaultErrorMsg = [...]; + +// ... validatePassword function ... + +// Examples: + +// Example 1: Valid password with default options +const result1 = validatePassword("MyP@ssw0rd", { minLength: 8, maxLength: 20 }); +console.log(result1); +// Output: { isValid: true, errorMsg: null } + +// Example 2: Weak password with missing uppercase letter +const result2 = validatePassword("weakpassword1!", { + minLength: 8, + maxLength: 20, + options: { + requireUppercase: true, + }, +}); +console.log(result2); +// Output: { isValid: false, errorMsg: 'Requires at least one capital letter' } + +// Example 3: Invalid password with too short length +const result3 = validatePassword("Pwd1!", { + minLength: 10, + maxLength: 20, + options: { + requireUppercase: true, + requireSpecialChar: true, + }, +}); +console.log(result3); +// Output: { isValid: false, errorMsg: 'password too short' } + +// Example 4: Valid password with custom error message +const myCustomErrorMsg = [ + "Custom error: Invalid format", + "Custom error: Invalid password", + "Custom error: Unknown error", +]; +const result4 = validatePassword("MyP@ssw0rd", { + minLength: 8, + maxLength: 20, + options: { + requireUppercase: true, + requireSpecialChar: true, + requireNumber: true, + requireString: true, + }, + errorMsg: myCustomErrorMsg, +}); +console.log(result4); +// Output: { isValid: true, errorMsg: null } + +// Example 5: Invalid password with missing special character +const result5 = validatePassword("WeakPassword1", { + minLength: 8, + maxLength: 20, + options: { + requireSpecialChar: true, + }, +}); +console.log(result5); +// Output: { isValid: false, errorMsg: 'Requires at least one special character' } + +/* +Example 6: Valid password with custom error message +for special character requirement +*/ +const myCustomErrorMsg2 = [...defaultErrorMsg]; +myCustomErrorMsg2[3] = "Custom error: Requires at least one special character"; +const result6 = validatePassword("MyP@ssw0rd", { + minLength: 8, + maxLength: 20, + options: { requireSpecialChar: true }, + errorMsg: myCustomErrorMsg2, +}); +console.log(result6); +// Output: { isValid: true, errorMsg: null } + +// Example 7: Invalid password with missing number +const result7 = validatePassword("StrongPwd@", { + minLength: 8, + maxLength: 20, + options: { requireNumber: true }, +}); +console.log(result7); +// Output: { isValid: false, errorMsg: 'Requires at least one number' } + +// Example 8: Invalid password with missing letter +const result8 = validatePassword("12345@#", { + minLength: 8, + maxLength: 20, + options: { requireString: true }, +}); +console.log(result8); +// Output: { isValid: false, errorMsg: 'Requires at least one letter' } + +// Example 9: Invalid password exceeding maximum length +const result9 = validatePassword("VeryLongPassword1234567890!@#$%^", { + minLength: 8, + maxLength: 20, +}); +console.log(result9); +// Output: { isValid: false, errorMsg: 'This password is too long' } + +// Example 10: Invalid input (non-string password) +try { + const result10 = validatePassword(123456, { + minLength: 8, + maxLength: 20, + options: { requireUppercase: true }, + }); + console.log(result10); // This will not execute +} catch (error) { + console.log(error.message); // Output: "The input should be a string." +}`} + +
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/functions/validatePhoneNumber/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/validatePhoneNumber/page.tsx new file mode 100644 index 0000000..b820ee4 --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/validatePhoneNumber/page.tsx @@ -0,0 +1,80 @@ +import "@/css/functions.css"; + +import { setStaticParamsLocale } from "next-international/server"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import DrawerComponent from "@/components/Drawer"; +import { getScopedI18n } from "@/locales/server"; + +export default async function ValidatePhoneNumber({ + params: { locale }, +}: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationJsFunctions"); + + return ( +
+
+ +
+
+

+ Phone Number Validation {t("Function Documentation")} +

+

+ {t("The")} validatePhoneNumber{" "} + {t( + 'Function is used to validate phone numbers. It returns an object with two properties: "isValid" (boolean) and "errorMsg" (string). The "isValid" property will be true if the phone number meets the specified criteria, and "errorMsg" will contain the error message if the phone number is invalid, or it will be null if the phone number is valid.', + )} +

+ +

{t("Function Signature")}

+ + {`function validatePhoneNumber( + phoneNumber: string, + errorMsg?: string[] +): { isValid: boolean, errorMsg: string | null };`} + + +

{t("Parameters")}

+
    +
  • + phoneNumber (string) -{" "} + {t("The phone number to be validated.")} +
  • +
  • + errorMsg (string[]) {t("[optional]")} -{" "} + {t( + "An array of error messages to customize the response. If not provided, the function will use default error messages.", + )} +
  • +
+ +

{t("Default Error Messages")}

+ + {`[ + 'Invalid value passed', + 'Invalid phone number', + 'Unknown error', +]`} + + +

{t("Examples")}

+ + + {`const result1 = validatePhoneNumber('555-123-4567'); +console.log(result1); +// Output: { isValid: false, errorMsg: 'Invalid phone number' } + +const customErrorMsg = [null, 'Custom error 2']; +const result2 = validatePhoneNumber('(555) 123-4567', customErrorMsg); +console.log(result2); +// Output: { isValid: false, errorMsg: 'Custom error 2' }`} + +
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/functions/validateSurname/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/validateSurname/page.tsx new file mode 100644 index 0000000..765a7d4 --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/validateSurname/page.tsx @@ -0,0 +1,100 @@ +import "@/css/functions.css"; + +import { setStaticParamsLocale } from "next-international/server"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import DrawerComponent from "@/components/Drawer"; +import { getScopedI18n } from "@/locales/server"; + +export default async function ValidateSurname({ + params: { locale }, +}: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationJsFunctions"); + + return ( +
+
+ +
+
+

+ Surname Validation {t("Function Documentation")} +

+

+ {t("The")} validateSurname{" "} + {t( + "function is used to validate surnames. It returns an object with two properties: 'isValid' (boolean) and 'errorMsg' (string). The 'isValid' property will be true if the surname meets the specified criteria, and 'errorMsg' will contain the error message if the surname is invalid, or it will be null if the surname is valid.", + )} +

+ +

{t("Function Signature")}

+ + {`function validateSurname( + surname: string, + { + minLength?: number, + maxLength?: number, + errorMsg?: string[] + } +): { isValid: boolean, errorMsg: string | null };`} + + +

{t("Parameters")}

+
    +
  • + surname (string) - {t("The surname to be validated.")} +
  • +
  • + minLength (number) {t("[optional]")} -{" "} + {t("The minimum length of the surname. Default is 1.")} +
  • +
  • + maxLength (number) {t("[optional]")} -{" "} + {t("The maximum length of the surname. Default is 25.")} +
  • +
  • + errorMsg (string[]) {t("[optional]")} -{" "} + {t( + "An array of error messages to customize the response. If not provided, the function will use default error messages.", + )} +
  • +
+ +

{t("Default Error Messages")}

+ + {`[ + 'Invalid value passed', + 'Surname cannot contain numbers', + 'Surname cannot contain special characters', + 'This surname is not valid', + 'Surname too big, try again', + 'Unknown error', +]`} + + +

{t("Examples")}

+ + {`const result1 = validateSurname("Jackson", { + minLength: 3, + maxLength: 25, +}); +console.log(result1); +// Output: { isValid: true, errorMsg: null } + +const customErrorMsg = [null, "Custom error 2"]; +const result2 = validateSurname("J@ckson", { + minLength: 3, + maxLength: 25, + errorMsg: customErrorMsg, +}); +console.log(result2); +// Output: { isValid: false, errorMsg: 'Surname cannot contain special characters' }`} + +
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/functions/validateTextarea/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/validateTextarea/page.tsx new file mode 100644 index 0000000..23146c8 --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/validateTextarea/page.tsx @@ -0,0 +1,123 @@ +import "@/css/functions.css"; + +import { setStaticParamsLocale } from "next-international/server"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import DrawerComponent from "@/components/Drawer"; +import { getScopedI18n } from "@/locales/server"; + +export default async function ValidateTextarea({ + params: { locale }, +}: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationJsFunctions"); + + return ( +
+
+ +
+
+

+

+ validateTextarea +

{" "} + {t("Function Documentation")} +

+

+ {t( + "This function is a text area validation utility that checks the validity of a given textarea string based on certain criteria.", + )} +

+ +

{t("Function Signature")}

+ + + {`/** +* @param {string} textarea - The input textarea string to be validated. +* @param {boolean} [isRequired=false] - A boolean flag to determine if the textarea is required (default: false). +* @param {number} [maxLength=50] - The maximum allowed length for the textarea (default: 50). +* @param {string[]} [errorMsg=defaultErrorMsg] - An array of custom error messages for different validation conditions (default: predefined messages). +* @default isRequired boolean: default: false +* @default maxLength number: default: 50 +* @example validateTextarea(); +* @example validateTextarea(); +* @example validateTextarea(); +* @description This function returns an object with two properties: 'isValid' (boolean) and 'errorMsg' (string). +* The 'isValid' property indicates if the textarea is valid based on the given criteria, and 'errorMsg' contains the corresponding error message, if any. +*/`} + + +

{t("Parameters")}

+
    +
  • + textarea (string):{" "} + {t("The input textarea string to be validated.")} +
  • +
  • + isRequired (boolean, optional, default: false):{" "} + {t("A flag to determine if the textarea is required.")} +
  • +
  • + maxLength (number, optional, default: 50):{" "} + {t("The maximum allowed length for the textarea.")} +
  • +
  • + errorMsg (string array, optional, default: + predefined messages):{" "} + {t( + "An array of custom error messages for different validation conditions. The array should contain three elements corresponding to different error scenarios. If not provided, default error messages will be used. Default Error Messages:", + )} +
      +
    • {t('Index 0: "This textarea is too big"')}
    • +
    • {t('Index 1: "Can not be empty"')}
    • +
    • {t('Index 2: "Unknown error"')}
    • +
    +
  • +
+ +

{t("Return Value")}

+

+ {t("The function returns an object with two properties:")} +

    +
  • + isValid (boolean):{" "} + {t( + "Indicates if the textarea is valid based on the given criteria.", + )} +
  • +
  • + errorMsg (string):{" "} + {t( + "Contains the corresponding error message, if any, based on the validation result.", + )} +
  • +
+

+ +

{t("Usage Examples")}

+ + + {`validateTextarea("Some text content"); // Example 1 +// Returns: { isValid: true, errorMsg: null } + +validateTextarea("", { isRequired: true }); // Example 2 +// Returns: { isValid: false, errorMsg: 'Can not be empty' } + +validateTextarea("Very long text...", { isRequired: false, maxLength: 10 }); // Example 3 +// Returns: { isValid: false, errorMsg: 'This textarea is too big' }`} + + +

+ {t("Note:")}{" "} + {t( + "The examples provided demonstrate how to use the function with different parameters and show the expected return values.", + )} +

+
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/functions/validateUSPhoneNumber/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/validateUSPhoneNumber/page.tsx new file mode 100644 index 0000000..56af6f3 --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/validateUSPhoneNumber/page.tsx @@ -0,0 +1,104 @@ +import "@/css/functions.css"; + +import { setStaticParamsLocale } from "next-international/server"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import DrawerComponent from "@/components/Drawer"; +import { getScopedI18n } from "@/locales/server"; + +export default async function validateUSPhoneNumber({ + params: { locale }, +}: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationJsFunctions"); + + return ( +
+
+ +
+
+

+ US Phone Number Validation {t("Function Documentation")} +

+

+ {t("The")} validateUSPhoneNumber{" "} + {t( + 'function is used to validate US phone numbers. It supports various formats, including "XXX-XXX-XXXX", "(XXX) XXX-XXXX", and "1 (XXX) XXX-XXXX". It returns an object with two properties: "isValid" (boolean) and "errorMsg" (string). The "isValid" property will be true if the phone number is valid, and "errorMsg" will contain the error message if the phone number is invalid, or it will be null if the phone number is valid.', + )} +

+ +

Import

+

+ {t( + 'The function can be imported using ES6 syntax from the "multiform-validator" package:', + )} +

+ + + {`import { validateUSPhoneNumber } from 'multiform-validator';`} + + +

+ {t( + "Alternatively, you can import the function using CommonJS syntax with", + )}{" "} + require (Node.js): +

+ + + {`const { validateUSPhoneNumber } = require('multiform-validator');`} + + +

{t("Function Signature")}

+ + + {`function validateUSPhoneNumber( + phoneNumber: string, + errorMsg?: string[] +): { isValid: boolean, errorMsg: string | null };`} + + +

{t("Parameters")}

+
    +
  • + phoneNumber (string) -{" "} + {t("The US phone number to be validated.")} +
  • +
  • + errorMsg (string[]){" "} + {t( + "[optional] - An array of error messages to customize the response. If not provided, the function will use default error messages.", + )} +
  • +
+ +

{t("Default Error Messages")}

+ + + {`[ + 'Invalid value passed', + 'Invalid phone number', + 'Unknown error' +]`} + + +

{t("Examples")}

+ + + {`const result1 = validateUSPhoneNumber('555-123-4567'); +console.log(result1); +// Output: { isValid: true, errorMsg: null } + +const customErrorMsg = ['Custom error 1', 'Custom error 2']; +const result2 = validateUSPhoneNumber('(555) 123-4567', customErrorMsg); +console.log(result2); +// Output: { isValid: false, errorMsg: 'Invalid phone number' }`} + +
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/functions/validateUsername/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/validateUsername/page.tsx new file mode 100644 index 0000000..ac8f97c --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/functions/validateUsername/page.tsx @@ -0,0 +1,139 @@ +import "@/css/functions.css"; + +import { setStaticParamsLocale } from "next-international/server"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import DrawerComponent from "@/components/Drawer"; +import { getScopedI18n } from "@/locales/server"; + +export default async function ValidateUsername({ + params: { locale }, +}: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationJsFunctions"); + + return ( +
+
+ +
+
+

+ Username Validation {t("Function Documentation")} +

+

+ {t("The")} validateUsername{" "} + {t( + 'function is used to validate usernames. It returns an object with two properties: "isValid" (boolean) and "errorMsg" (string). The "isValid" property will be true if the username meets the specified criteria, and "errorMsg" will contain the error message if the username is invalid, or it will be null if the username is valid.', + )} +

+ +

Import

+

+ {t( + 'The function can be imported using ES6 syntax from the "multiform-validator" package:', + )} +

+ + + {`import { validateUsername } from 'multiform-validator';`} + + +

+ {t( + "Alternatively, you can import the function using CommonJS syntax with", + )}{" "} + require (Node.js): +

+ + + {`const { validateUsername } = require('multiform-validator');`} + + +

{t("Function Signature")}

+ + + {`interface OptionsParams { + minLength?: number; + maxLength?: number; + errorMsg?: (string | null)[]; +} + +const defaultOptionsParams: OptionsParams = { + minLength: 1, + maxLength: infinity, + errorMsg: defaultErrorMsg, +}; + +function validateUsername( + username: string, + { minLength, maxLength, errorMsg }: OptionsParams = defaultOptionsParams, +): { isValid: boolean, errorMsg: string | null };`} + + +

{t("Parameters")}

+
    +
  • + username (string) -{" "} + {t("The username to be validated.")} +
  • +
  • + minLength (number){" "} + {t( + "[optional] - The minimum length of the username. Default is 1.", + )} +
  • +
  • + maxLength (number){" "} + {t( + "[optional] - The maximum length of the username. Default is Infinity.", + )} +
  • +
  • + errorMsg (string[]){" "} + {t( + "[optional] - An array of error messages to customize the response. If not provided, the function will use default error messages.", + )} +
  • +
+ +

{t("Default Error Messages")}

+ + + {`[ + 'Invalid value passed', + 'Username too short', + 'This username is too long', + 'Username cannot contain spaces', + 'Cannot start with a number', + 'Cannot contain only numbers', + 'Unknown error' +]`} + + +

{t("Examples")}

+ + + {`const result1 = validateUsername("User999", { + minLength: 8, + maxLength: 20, +}); +console.log(result1); +// Output: { isValid: true, errorMsg: null } + +const customErrorMsg = ["Custom error 1", "Custom error 2"]; +const result2 = validateUsername("User999", { + minLength: 8, + maxLength: 20, + errorMsg: customErrorMsg, +}); +console.log(result2); +// Output: { isValid: false, errorMsg: 'Username too short' }`} + +
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/layout.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/layout.tsx new file mode 100644 index 0000000..bea29ee --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/layout.tsx @@ -0,0 +1,13 @@ +import type { Metadata } from "next"; + +export const metadata: Metadata = { + title: "Javascript", +}; + +export default function JavascriptDocumentationLayout({ + children, +}: Readonly<{ + children: React.ReactNode; +}>) { + return <>{children}; +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/page.tsx new file mode 100644 index 0000000..4f2dd67 --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/page.tsx @@ -0,0 +1,301 @@ +import Image from "next/image"; +import Link from "next/link"; +import { setStaticParamsLocale } from "next-international/server"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import DrawerComponent from "@/components/Drawer"; +import { getScopedI18n } from "@/locales/server"; + +import { + Cdns, + Installation, + UsageCDNExample, + UsageExample, +} from "./subComponents/MainPageSyntexHightlighter"; + +export default async function DocumentationPageJs({ + params: { locale }, +}: LocaleParams) { + setStaticParamsLocale(locale); + + const route = locale === "pt" ? "/pt" : "/"; + + const t = await getScopedI18n("DocumentationJs"); + return ( +
+
+ {/** */} +
+
+ + {t("Back to home page")} + + +
+
+

+ {t("Official documentation")} +

+

{t("Welcome Introduction Text")}

+
+

+ Multiform-validator +

+ +

+ + npm version + + + License: MIT + + + npm downloads + +

+ +

+ {t( + "This npm package provides JavaScript functions to validate various forms fields.", + )} +

+ +

+ {t("If you want to help me, you can buy me a coffee (:")} +

+ +

+ + Buy Me A Coffee{" "} + +

+ + +

{t("INFO: ")}

+

{t("FirstInfoText")}

+

{t("SecondInfoText")}

+
+ +

{t("Feel free to find bugs Text Msg")}

+ +

CDN's

+ +
+ +
+ +

+ {t("Example of use with CDN")} +

+ +
+ +
+ +

{t("Installation")}

+ + + +

{t("Data Validator")}

+ +

+ {t( + "This package contains various modules for validating different types of data. Below are the available validation modules:", + )} +

+ +

+ {t("Available Validation Modules")} +

+ +
    +
  • + cnpjValidator: CNPJ validation. +
  • +
  • + cpfValidator: CPF validation. +
  • +
  • + getOnlyEmail: Extracts only the email or + emails address from a string. +
  • +
  • + identifyFlagCard: Identifies the flag of a + credit card. +
  • +
  • + isAscii: Checks if the string contains only + ASCII characters. +
  • +
  • + isBase64: Checks if the string is a valid + Base64 encoding. +
  • +
  • + isCEP: CEP validation (Brazilian postal + code). +
  • +
  • + isCreditCardValid: Credit card validation. +
  • +
  • + isDate: Date format validation. +
  • +
  • + isDecimal: Checks if the number is a decimal. +
  • +
  • + isEmail: Email address validation format. +
  • +
  • + isEmpty: Checks if the string is empty. +
  • +
  • + isMACAddress: MAC address validation. +
  • +
  • + isMD5: Checks if the string is a valid MD5 + hash. +
  • +
  • + isNumber: Checks if the value is a number. +
  • +
  • + isPort: Port number validation. +
  • +
  • + isPostalCode: Postal code validation. +
  • +
  • + isTime: Time format validation. +
  • +
  • + isValidAudio Audio file validation. +
  • +
  • + isValidImage Image file validation. +
  • +
  • + isValidPdf Pdf file validation. +
  • +
  • + isValidTxt Txt file validation. +
  • +
  • + isValidVideo Video file validation. +
  • +
  • + passwordStrengthTester: Password strength + test. +
  • +
  • + validateBRPhoneNumber: Brazilian phone number + validation. +
  • +
  • + validateEmail: Email address full validation. +
  • +
  • + validateName: Name validation. +
  • +
  • + validatePassportNumber: Passport number + validation. +
  • +
  • + validatePassword: Password validation. +
  • +
  • + validatePhoneNumber: Phone number validation. +
  • +
  • + validateSurname: Surname validation. +
  • +
  • + validateTextarea: Textarea validation. +
  • +
  • + validateUsername: Username validation. +
  • +
  • + validateUSPhoneNumber: US phone number + validation. +
  • +
+ +

+ {t("if you prefer, you can use importing as:")} +

+ +
+ +
+ +

+ {t("If you want to help me, you can buy me a coffee (:")} +

+ +

+ + Buy Me A Coffee{" "} + +

+ +

{t("Feel free to explore msg")}

+ +

{t("By - Gabriel Logan")}

+
+
+
+ {/** */} +
+ {/** */} +
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/js/subComponents/MainPageSyntexHightlighter.tsx b/docs/src/app/[locale]/(doc-session)/documentation/js/subComponents/MainPageSyntexHightlighter.tsx new file mode 100644 index 0000000..0cb003c --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/js/subComponents/MainPageSyntexHightlighter.tsx @@ -0,0 +1,94 @@ +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +export function Installation() { + return ( + <> +
+ + npm install multiform-validator + +
+ +
+ + yarn add multiform-validator + +
+ + ); +} + +export function UsageExample() { + return ( + + {`const validator = require('multiform-validator'); +// or +import validator from 'multiform-validator'; + +Attention, FUNCTION_NAME is not a valid function name! +It is just an example of how to import the functions. + +const { FUNCTION_NAME } = require('multiform-validator'); +// or +import { FUNCTION_NAME } from 'multiform-validator'; + +/** +* There are other returns in some functions, with strings etc, stay tuned +*/`} + + ); +} + +export function UsageCDNExample() { + return ( + + {` + +`} + + ); +} + +export function Cdns() { + return ( + <> +
+

jsDelivr

+ + https://cdn.jsdelivr.net/npm/multiform-validator@2.1.0/dist/bundle.min.js + + + {``} + +
+
+

unpkg

+ + https://unpkg.com/multiform-validator@2.1.0/dist/bundle.js + + + {``} + +
+ + ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/page.tsx new file mode 100644 index 0000000..af050f8 --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/page.tsx @@ -0,0 +1,71 @@ +import Image from "next/image"; +import Link from "next/link"; +import { setStaticParamsLocale } from "next-international/server"; +import { RiJavascriptFill } from "react-icons/ri"; + +import javaIcon from "@/assets/icons/java-icon.svg"; +import pythonIcon from "@/assets/icons/python-icon.svg"; +import MainBg from "@/components/MainBg"; +import { getScopedI18n } from "@/locales/server"; + +import { LocaleParams } from "../../types/locale"; + +export default async function DocumentationPage({ + params: { locale }, +}: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationPage"); + + const basePath = `/${locale}/documentation`; + return ( + +
+

+ {t("doc_title")} +

+

+ {t("doc_intro")} +

+

+ {t("doc_subtitle")} +

+
+ + +

+ {t("doc_js_title")} +

+

{t("doc_js_text")}

+ + + python-icon +

+ {t("doc_py_title")} +

+

{t("doc_py_text")}

+ + + java-icon +

+ {t("doc_java_title")} +

+

{t("doc_java_text")}

+

+ {t("doc_java_coming")} +

+ +
+
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/py/layout.tsx b/docs/src/app/[locale]/(doc-session)/documentation/py/layout.tsx new file mode 100644 index 0000000..c71e276 --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/py/layout.tsx @@ -0,0 +1,13 @@ +import type { Metadata } from "next"; + +export const metadata: Metadata = { + title: "Python", +}; + +export default function PythonDocumentationLayout({ + children, +}: Readonly<{ + children: React.ReactNode; +}>) { + return <>{children}; +} diff --git a/docs/src/app/[locale]/(doc-session)/documentation/py/page.tsx b/docs/src/app/[locale]/(doc-session)/documentation/py/page.tsx new file mode 100644 index 0000000..8e2aa82 --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/documentation/py/page.tsx @@ -0,0 +1,227 @@ +import Image from "next/image"; +import Link from "next/link"; +import { setStaticParamsLocale } from "next-international/server"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; + +import { LocaleParams } from "@/app/[locale]/types/locale"; +import { getScopedI18n } from "@/locales/server"; + +export default async function DocumentationPagePy({ + params: { locale }, +}: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationPython"); + + return ( +
+

Python Doc

+ + {t("Back to home")} + +

+ + pypi version + + + License: MIT + + + pypi downloads + +

+
+

{t("Installation")}

+

{t("Install the package using pip: ")}

+ + pip install multiform-validator + + + + {`from multiform_validator import ( + cnpjIsValid, + cpfIsValid, + getOnlyEmail, + identifyFlagCard, + isCreditCardValid, + isEmail, + passwordStrengthTester, + validateBRPhoneNumber, + isValidImage +)`} + +
+
+

{t("Methods")}

+
+

isEmail:

+ + {`print("Is email", isEmail("foo@bar.com")) # True + +print("Is not email", isEmail("foo@bar")) # False`} + +
+
+

getOnlyEmail:

+ + {`print("Get only email", getOnlyEmail("awdawd wadawd wda awd jhony@gmail.com awdawdawd")) +# jhony@gmail.com + +print("Multiple emails", getOnlyEmail("dawd foo@bar.com adwda wdaw da @dadwa odiw jon@foob.com", True)) +# ['foo@bar.com', 'jon@foob.com'] + +print("Multiple and cleanDomains", getOnlyEmail( + """ + awawdi wadwad iu awd foor@bar.comAOWDowad wdaoiwdo @OIDOim2o2OID@AD@D@@@@D odi2 2oid2odi2D + aodo2d@doaiaod jhon@bar.com.brADW + """, True, True +)) # ['foor@bar.com', 'jhon@bar.com.br'] + +print("Multiple, clean and repeat emails", getOnlyEmail( + """ + awawdi wadwad iu awd u awd foor@bar.comAOWDowad wda u + 2d@doaiaod jhon@bar.com.brADW + awd foor@bar.comAOWDowad wda + """, True, True, True +)) # ['foor@bar.com', 'jhon@bar.com.br', 'foor@bar.com'] + +# Each parameter can be passed as false individually, the default for all is false`} + +
+
+

identifyFlagCard:

+ + {`print("Identify flag card", identifyFlagCard("5117 2161 1334 8362")) # Mastercard`} + +
+
+

passwordStrengthTester:

+ + {`print("Password strength", passwordStrengthTester("aA1!asd@qd2asd")) # Very Strong`} + +
+
+

cpfIsValid:

+ + {`print("Is CPF valid", cpfIsValid("123.456.789-02")['isValid']) # False + +print("Is CPF valid", cpfIsValid("123.456.789-09")) +# {'isValid': False, 'errorMsg': 'CNPJ is not valid'}`} + +
+
+

cnpjIsValid:

+ + {`print("Is CNPJ valid", cnpjIsValid("12.345.678/0001-09")) +# { 'isValid': False, 'errorMsg': 'CNPJ is not valid' }`} + +
+
+

isCreditCardValid:

+ + {`print("Is credit card valid", isCreditCardValid("5117 2161 1334 8362")) # True`} + +
+
+

isCreditCardValid:

+ + {`print("Is credit card valid", isCreditCardValid("5117 2161 1334 8362")) # True`} + +
+
+

validateBRPhoneNumber:

+ + {`print("Validate BR phone number", validateBRPhoneNumber("(11) 91234-5678")) +# { 'isValid': True, 'errorMsg': None }`} + +
+
+

isValidImage:

+ + {`import os +from pathlib import Path + +from multiform_validator import isValidImage + +# Resolve the file path +file_path = Path.cwd() / 'static' / 'uploads' +retrieved_file = file_path / filename + +# Read the first 4 bytes of the file +with open(retrieved_file, 'rb') as f: + file_buffer = f.read(4) + +print(isValidImage(file_buffer)) # True or False`} + +
+
+
+

{t("Functions signature")}

+

{t("All params with default values are optional.")}

+ + {`def isEmail(email: str) -> bool: + pass + +def getOnlyEmail(text: str, multiple=False, clean_domain=False, repeat_email=False) -> str: + pass + +def passwordStrengthTester(password: str) -> str: + pass + +defaultErrorMsgCPF = [ + 'CPF invalid', + 'CPF must have 11 numerical digits', + 'CPF is not valid', + 'Unknown error', +] +def cpfIsValid(cpf: str, errorMsg=defaultErrorMsgCPF) -> Dict[str, Union[bool, str, None]]: + pass + +default_error_msgCNPJ = [ + 'CNPJ invalid', + 'CNPJ must have 14 numerical digits', + 'CNPJ is not valid', + 'Unknown error' +] +def cnpjIsValid(cnpj: str, errorMsg=default_error_msgCNPJ) -> Dict[str, Union[bool, str, None]]: + pass + +def isCreditCardValid(cardNumber: str) -> bool: + pass + +def identifyFlagCard(cardNumber: str) -> str: + pass + +default_error_msg = ['Invalid value passed', 'Invalid phone number', 'Unknown error'] +def validateBRPhoneNumber(phoneNumber: str, errorMsg=default_error_msg) -> Dict[str, Union[bool, str, None]]: + pass + +def isValidImage(file_buffer: bytes) -> bool: + pass`} + +
+
+ ); +} diff --git a/docs/src/app/[locale]/(doc-session)/layout.tsx b/docs/src/app/[locale]/(doc-session)/layout.tsx new file mode 100644 index 0000000..5cc5939 --- /dev/null +++ b/docs/src/app/[locale]/(doc-session)/layout.tsx @@ -0,0 +1,35 @@ +import "react-modern-drawer/dist/index.css"; + +import type { Metadata } from "next"; +import { setStaticParamsLocale } from "next-international/server"; + +import { getScopedI18n } from "@/locales/server"; + +import { LocaleParams } from "../types/locale"; + +export async function generateMetadata({ + params: { locale }, +}: LocaleParams): Promise { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("DocumentationLayout"); + + return { + title: { + template: `${t("Documentation")} | %s`, + default: t("Documentation"), + }, + description: t("Documentation for the Multiform Validator library."), + }; +} + +type DocumentationLayoutProps = Readonly<{ + children: React.ReactNode; + params: { locale: string }; +}>; + +export default function DocumentationLayout({ + children, +}: DocumentationLayoutProps) { + return <>{children}; +} diff --git a/docs/src/app/[locale]/about/page.tsx b/docs/src/app/[locale]/about/page.tsx new file mode 100644 index 0000000..3d729ab --- /dev/null +++ b/docs/src/app/[locale]/about/page.tsx @@ -0,0 +1,42 @@ +import "@/css/infos.css"; +import { Metadata } from "next"; +import { setStaticParamsLocale } from "next-international/server"; + +import MainBg from "@/components/MainBg"; +import { getScopedI18n } from "@/locales/server"; + +import { LocaleParams } from "../types/locale"; + +export async function generateMetadata({ + params: { locale }, +}: LocaleParams): Promise { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("About"); + + return { + title: t("About_Page"), + description: t("About_Page_Description"), + }; +} + +export default async function AboutPage({ params: { locale } }: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("About"); + + return ( + +
+

{t("about_title")}

+

{t("about_intro")}

+

{t("about_frontend")}

+

{t("about_backend")}

+

{t("about_achievement")}

+

{t("about_creative")}

+

{t("about_inspiration")}

+

{t("about_conclusion")}

+
+
+ ); +} diff --git a/docs/src/app/[locale]/info/page.tsx b/docs/src/app/[locale]/info/page.tsx new file mode 100644 index 0000000..68685cf --- /dev/null +++ b/docs/src/app/[locale]/info/page.tsx @@ -0,0 +1,42 @@ +import "@/css/infos.css"; +import { Metadata } from "next"; +import { setStaticParamsLocale } from "next-international/server"; + +import MainBg from "@/components/MainBg"; +import { getScopedI18n } from "@/locales/server"; + +import { LocaleParams } from "../types/locale"; + +export async function generateMetadata({ + params: { locale }, +}: LocaleParams): Promise { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("Info"); + + return { + title: t("Info_Page"), + description: t("info_title"), + }; +} + +export default async function InfoPage({ params: { locale } }: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("Info"); + + return ( + +
+

{t("info_title")}

+

{t("info_intro")}

+

{t("info_ensure")}

+

{t("info_prebuilt_rules")}

+

{t("info_backend")}

+

{t("info_flexibility")}

+

{t("info_performance")}

+

{t("info_conclusion")}

+
+
+ ); +} diff --git a/docs/src/app/[locale]/layout.tsx b/docs/src/app/[locale]/layout.tsx new file mode 100644 index 0000000..c57b231 --- /dev/null +++ b/docs/src/app/[locale]/layout.tsx @@ -0,0 +1,56 @@ +import type { Metadata } from "next"; +import { setStaticParamsLocale } from "next-international/server"; + +import { getScopedI18n, getStaticParams } from "@/locales/server"; + +import { LocaleParams } from "./types/locale"; + +export function generateStaticParams() { + return getStaticParams(); // PT and EN +} + +export async function generateMetadata({ + params: { locale }, +}: LocaleParams): Promise { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("HomeLayout"); + + return { + metadataBase: new URL( + `${process.env.NEXT_PUBLIC_WEBSITE_URL}/${locale}` || + `https://multiform-validator.3utilities.com/${locale}`, + ), + + description: t("Description"), + + classification: t("Classification"), + + openGraph: { + title: t("Opengraph title"), + description: t("Opengraph description"), + url: process.env.NEXT_PUBLIC_WEBSITE_URL, + siteName: t("Title"), + type: "website", + }, + + appleWebApp: { + title: t("Title"), + capable: true, + statusBarStyle: "black-translucent", + }, + + category: t("Technology"), + }; +} + +type DocumentationLayoutProps = Readonly<{ + children: React.ReactNode; + params: { locale: string }; +}>; + +export default function DocumentationLayout({ + children, +}: DocumentationLayoutProps) { + return <>{children}; +} diff --git a/docs/src/app/[locale]/page.tsx b/docs/src/app/[locale]/page.tsx new file mode 100644 index 0000000..e6f0f07 --- /dev/null +++ b/docs/src/app/[locale]/page.tsx @@ -0,0 +1,95 @@ +import Image from "next/image"; +import Link from "next/link"; +import { setStaticParamsLocale } from "next-international/server"; + +import MainBg from "@/components/MainBg"; +import { merriweather, oswald, playfair, roboto100, sofiaPro } from "@/fonts"; +import { getScopedI18n } from "@/locales/server"; + +import { LocaleParams } from "./types/locale"; + +export default async function Page({ params: { locale } }: LocaleParams) { + setStaticParamsLocale(locale); + + const t = await getScopedI18n("HomePage"); + + return ( + +

+ {t("Welcome")} +

+

+ {t("Intro")} +

+

+ {t("Hello")} (: +

+

+ {t("FollowThe")}{" "} + + {t("Documentation").toLowerCase()} + {" "} + {t("ForMoreInfo").toLowerCase()} +

+
+ + {t("SeeTheGithubSourceCode")} + + + {t("SeeTheNpmPage")} + + + {t("SeeThePypiPage")} + +
+ +

+ {t("HelpMsg")} +

+ +
+