Skip to content

Commit

Permalink
adding validSocialName and validDocumentDate
Browse files Browse the repository at this point in the history
  • Loading branch information
ammichael committed Oct 16, 2021
1 parent 51e4d7a commit b5e9d2a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@ 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) |
| [`isValidPhone`](./docs/isValidPhone.md) | truthy OR falsy | (string, number?) |
| [`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) |
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@platformbuilders/validations",
"version": "0.0.17",
"version": "0.0.18",
"description": "",
"author": "Platform Builders <[email protected]>",
"repository": {
Expand Down
11 changes: 11 additions & 0 deletions src/isValidDocumentDate.ts
Original file line number Diff line number Diff line change
@@ -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);
};
6 changes: 4 additions & 2 deletions src/isValidSocialName.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit b5e9d2a

Please sign in to comment.