availity-reactstrap-validation
Advanced tools
Comparing version 2.5.2 to 2.5.3
@@ -0,1 +1,16 @@ | ||
<a name="2.5.3"></a> | ||
## [2.5.3](https://github.com/Availity/availity-reactstrap-validation/compare/2.5.2...2.5.3) (2019-05-16) | ||
### Code Refactoring | ||
* replaced moment with dayjs ([f5a9ffa](https://github.com/Availity/availity-reactstrap-validation/commit/f5a9ffa)) | ||
### BREAKING CHANGES | ||
* moment has been replaced | ||
<a name="2.5.2"></a> | ||
@@ -2,0 +17,0 @@ ## [2.5.2](https://github.com/Availity/availity-reactstrap-validation/compare/2.5.0...2.5.2) (2019-04-26) |
@@ -6,6 +6,10 @@ 'use strict'; | ||
var _moment = require('moment'); | ||
var _dayjs = require('dayjs'); | ||
var _moment2 = _interopRequireDefault(_moment); | ||
var _dayjs2 = _interopRequireDefault(_dayjs); | ||
var _customParseFormat = require('dayjs/plugin/customParseFormat'); | ||
var _customParseFormat2 = _interopRequireDefault(_customParseFormat); | ||
var _utils = require('./utils'); | ||
@@ -15,6 +19,10 @@ | ||
_dayjs2.default.extend(_customParseFormat2.default); | ||
var defaultFormat = 'MM/DD/YYYY'; | ||
function validate(value, context) { | ||
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, | ||
_ref$format = _ref.format, | ||
format = _ref$format === undefined ? 'MM/DD/YYYY' : _ref$format, | ||
format = _ref$format === undefined ? defaultFormat : _ref$format, | ||
_ref$errorMessage = _ref.errorMessage, | ||
@@ -25,5 +33,9 @@ errorMessage = _ref$errorMessage === undefined ? 'Format needs to be ' + format : _ref$errorMessage; | ||
var date = (0, _moment2.default)(value, [_utils.isoDateFormat, format], true); | ||
var date = (0, _dayjs2.default)(value, format); | ||
if (format === defaultFormat && !date.isValid()) { | ||
date = (0, _dayjs2.default)(value, _utils.isoDateFormat); | ||
} | ||
return date.isValid() || errorMessage; | ||
} |
@@ -6,6 +6,14 @@ 'use strict'; | ||
var _moment = require('moment'); | ||
var _dayjs = require('dayjs'); | ||
var _moment2 = _interopRequireDefault(_moment); | ||
var _dayjs2 = _interopRequireDefault(_dayjs); | ||
var _isBetween = require('dayjs/plugin/isBetween'); | ||
var _isBetween2 = _interopRequireDefault(_isBetween); | ||
var _customParseFormat = require('dayjs/plugin/customParseFormat'); | ||
var _customParseFormat2 = _interopRequireDefault(_customParseFormat); | ||
var _utils = require('./utils'); | ||
@@ -15,2 +23,5 @@ | ||
_dayjs2.default.extend(_isBetween2.default); | ||
_dayjs2.default.extend(_customParseFormat2.default); | ||
function setMin(value) { | ||
@@ -33,7 +44,7 @@ value.set('hours', 0); | ||
function getStartDate(start) { | ||
return setMin((0, _moment2.default)().add(start.value, start.units)); | ||
return setMin((0, _dayjs2.default)().add(start.value, start.units)); | ||
} | ||
function getEndDate(end) { | ||
return setMax((0, _moment2.default)().add(end.value, end.units)); | ||
return setMax((0, _dayjs2.default)().add(end.value, end.units)); | ||
} | ||
@@ -58,5 +69,9 @@ | ||
var date = (0, _moment2.default)(value, [_utils.isoDateFormat, format], true); | ||
setMin(date); | ||
var date = (0, _dayjs2.default)(value, format); | ||
if (!date.isValid()) { | ||
date = (0, _dayjs2.default)(value, _utils.isoDateFormat); | ||
} | ||
date = setMin(date); | ||
if (!(0, _utils.isEmpty)(start.units) && !(0, _utils.isEmpty)(end.units)) { | ||
@@ -66,4 +81,4 @@ startDate = getStartDate(start); | ||
} else { | ||
startDate = (0, _moment2.default)(start.value, start.format || format); | ||
endDate = setMax((0, _moment2.default)(end.value, end.format || format)); | ||
startDate = (0, _dayjs2.default)(start.value, start.format || format); | ||
endDate = setMax((0, _dayjs2.default)(end.value, end.format || format)); | ||
} | ||
@@ -70,0 +85,0 @@ errorMessage = errorMessage || 'Date must be between ' + startDate.format(displayFormat) + ' and ' + endDate.format(displayFormat); |
@@ -6,6 +6,10 @@ 'use strict'; | ||
var _moment = require('moment'); | ||
var _dayjs = require('dayjs'); | ||
var _moment2 = _interopRequireDefault(_moment); | ||
var _dayjs2 = _interopRequireDefault(_dayjs); | ||
var _isSameOrBefore = require('dayjs/plugin/isSameOrBefore'); | ||
var _isSameOrBefore2 = _interopRequireDefault(_isSameOrBefore); | ||
var _toNumber = require('lodash/toNumber'); | ||
@@ -23,2 +27,4 @@ | ||
_dayjs2.default.extend(_isSameOrBefore2.default); | ||
function validate(value, context) { | ||
@@ -35,3 +41,3 @@ var constraint = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
if (input.validations && input.validations.date || input.props && input.props.type && input.props.type.toLowerCase() === 'date') { | ||
return (0, _moment2.default)(value, [_utils.isoDateFormat, constraint.format || 'MM/DD/YYYY'], true).isSameOrBefore(constraint.value, 'day') || constraint.errorMessage || false; | ||
return (0, _dayjs2.default)(value, [_utils.isoDateFormat, constraint.format || 'MM/DD/YYYY'], true).isSameOrBefore(constraint.value, 'day') || constraint.errorMessage || false; | ||
} | ||
@@ -38,0 +44,0 @@ |
@@ -6,6 +6,10 @@ 'use strict'; | ||
var _moment = require('moment'); | ||
var _dayjs = require('dayjs'); | ||
var _moment2 = _interopRequireDefault(_moment); | ||
var _dayjs2 = _interopRequireDefault(_dayjs); | ||
var _isSameOrAfter = require('dayjs/plugin/isSameOrAfter'); | ||
var _isSameOrAfter2 = _interopRequireDefault(_isSameOrAfter); | ||
var _toNumber = require('lodash/toNumber'); | ||
@@ -23,2 +27,4 @@ | ||
_dayjs2.default.extend(_isSameOrAfter2.default); | ||
function validate(value, context) { | ||
@@ -35,3 +41,3 @@ var constraint = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
if (input.validations && input.validations.date || input.props && input.props.type && input.props.type.toLowerCase() === 'date') { | ||
return (0, _moment2.default)(value, [_utils.isoDateFormat, constraint.format || 'MM/DD/YYYY'], true).isSameOrAfter(constraint.value, 'day') || constraint.errorMessage || false; | ||
return (0, _dayjs2.default)(value, [_utils.isoDateFormat, constraint.format || 'MM/DD/YYYY'], true).isSameOrAfter(constraint.value, 'day') || constraint.errorMessage || false; | ||
} | ||
@@ -38,0 +44,0 @@ |
{ | ||
"name": "availity-reactstrap-validation", | ||
"version": "2.5.2", | ||
"version": "2.5.3", | ||
"author": "Evan Sharp <evan.sharp@availity.com>", | ||
@@ -59,4 +59,4 @@ "description": "Form validation helpers for reactstrap", | ||
"classnames": "^2.2.6", | ||
"dayjs": "^1.8.13", | ||
"lodash": "^4.17.10", | ||
"moment": "^2.22.2", | ||
"prop-types": "^15.6.2" | ||
@@ -63,0 +63,0 @@ }, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3665491
22391
12
+ Addeddayjs@^1.8.13
+ Addeddayjs@1.11.13(transitive)
- Removedmoment@^2.22.2
- Removedmoment@2.30.1(transitive)