Skip to content

Commit

Permalink
bump v0.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
geoperez committed Aug 20, 2019
1 parent c4833a6 commit cf5b2ff
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 29 deletions.
4 changes: 2 additions & 2 deletions lib/functions/validations.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ValidatorForm } from 'react-form-validator-core';
export declare function isNotAllBlanks(value: any, minlength: number): boolean;
export declare function maxNaturalNumber(value: any, maxInt: any): boolean;
declare function validateEndDate(endValue: any, startValue: any): boolean;
declare function startDateGreaterThanEndDate(startValue: any, endValue: any): boolean;
declare function validateEndDate(endValue: string, startValue: string): boolean;
declare function startDateGreaterThanEndDate(startValue: string, endValue: string): boolean;
export { startDateGreaterThanEndDate, ValidatorForm, validateEndDate, };
17 changes: 6 additions & 11 deletions lib/functions/validations.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/functions/validations.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "uno-react",
"version": "0.8.1",
"version": "0.9.0",
"description": "Common functions, HOCs and hooks for React.",
"main": "lib/index.js",
"scripts": {
Expand Down Expand Up @@ -33,7 +33,7 @@
"@material-ui/icons": "^4.2.1",
"@material-ui/styles": "^4.3.0",
"@types/react": "16.9.2",
"@types/react-dom": "16.8.5",
"@types/react-dom": "16.9.0",
"parcel-bundler": "^1.12.3",
"parcel-plugin-clean-easy": "^1.0.2",
"react": "^16.9.0",
Expand All @@ -54,7 +54,7 @@
"lib"
],
"dependencies": {
"date-fns": "^1.30.1",
"date-fns": "^2.0.0",
"react-form-validator-core": "^0.6.4"
}
}
19 changes: 7 additions & 12 deletions src/functions/validations.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import differenceInMinutes from 'date-fns/difference_in_minutes';
import parse from 'date-fns/parse';
import differenceInMinutes from 'date-fns/differenceInMinutes';
import parseISO from 'date-fns/parseISO';
import { ValidatorForm } from 'react-form-validator-core';

const lettersRegex = new RegExp('^(?=.*[a-z])(?=.*[A-Z])');
Expand All @@ -26,21 +26,16 @@ ValidatorForm.addValidationRule('isNotAllBlanks', isNotAllBlanks);

ValidatorForm.addValidationRule('maxNaturalNumber', maxNaturalNumber);

function validateEndDate(endValue: any, startValue: any) {
const startDate = parse(startValue);
const endDate = parse(endValue);
function validateEndDate(endValue: string, startValue: string) {
const startDate = parseISO(startValue);
const endDate = parseISO(endValue);
return (differenceInMinutes(endDate, startDate) > 0);
}

ValidatorForm.addValidationRule('validateEndDate', validateEndDate);

function startDateGreaterThanEndDate(startValue: any, endValue: any) {
if (endValue !== null) {
const startDate = parse(startValue);
const endDate = parse(endValue);
return (differenceInMinutes(endDate, startDate) > 0);
}
return true;
function startDateGreaterThanEndDate(startValue: string, endValue: string) {
return endValue !== null ? validateEndDate(endValue, startValue) : true;
}

ValidatorForm.addValidationRule('startDateGreaterThanEndDate', startDateGreaterThanEndDate);
Expand Down

0 comments on commit cf5b2ff

Please sign in to comment.