diff --git a/README.md b/README.md index 4087079..144b61b 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ import { isValidFullName } from '@platformbuilders/validations' | [`isValidCurrency`](./docs/isValidCurrency.md) | truthy OR falsy | (string) | | [`isValidDDD`](./docs/isValidDDD.md) | truthy OR falsy | (string) | | [`isValidDocument`](./docs/isValidDocument.md) | truthy OR falsy | (string) | +| [`isValidDocumentDate`](./docs/isValidDocumentDate.md) | truthy OR falsy | (string) | | [`isValidEmail`](./docs/isValidEmail.md) | truthy OR falsy | (string) | | [`isValidFullName`](./docs/isValidFullName.md) | truthy OR falsy | (string) | | [`isValidPassword`](./docs/isValidPassword.md) | truthy OR falsy | (string) | @@ -56,3 +57,4 @@ import { isValidFullName } from '@platformbuilders/validations' | [`isValidPin`](./docs/isValidPin.md) | truthy OR falsy | (string, number?) | | [`isValidPositiveValue`](./docs/isValidPositiveValue.md) | truthy OR falsy | (string) | | [`isValidSocialName`](./docs/isValidSocialName.md) | truthy OR falsy | (string) | +| [`isValidNickName`](./docs/isValidNickName.md) | truthy OR falsy | (string) | diff --git a/package.json b/package.json index c361dc6..37366a7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@platformbuilders/validations", - "version": "0.0.17", + "version": "0.0.18", "description": "", "author": "Platform Builders ", "repository": { diff --git a/src/isValidDocumentDate.ts b/src/isValidDocumentDate.ts new file mode 100644 index 0000000..9d11dca --- /dev/null +++ b/src/isValidDocumentDate.ts @@ -0,0 +1,11 @@ +import DateManager from 'moment'; + +const SCREEN_DATE = 'DD/MM/YYYY'; + +export const isValidDocumentDate = (date?: string): boolean => { + const maxAge = 95; + const minDate = DateManager().subtract(maxAge, 'years'); + const maxDate = DateManager().add(1, 'day'); + const insertedDate = DateManager(date, SCREEN_DATE); + return insertedDate.isBetween(minDate, maxDate); +}; diff --git a/src/isValidSocialName.ts b/src/isValidSocialName.ts index 04ab362..cff76ba 100644 --- a/src/isValidSocialName.ts +++ b/src/isValidSocialName.ts @@ -1,6 +1,8 @@ -export const isValidSocialName = (socialName?: string): boolean => - !!socialName && socialName.length >= 2; +export const isValidSocialName = (socialName: string): boolean => + !!socialName && socialName.length >= 2 && socialName.length <= 10; +export const isValidNickName = (nickName: string): boolean => + !!nickName && nickName.length >= 3 && nickName.length <= 10; /** * Validates a social name and the criteria to approve a social is: * * Must have only letters