main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
762 bytes
|
Rev | Line | |
---|
[d24f17c] | 1 | import { invoker, both, pipe, curryN } from 'ramda';
|
---|
| 2 |
|
---|
| 3 | import isDate from './isDate';
|
---|
| 4 | import isNotNaN from './isNotNaN';
|
---|
| 5 |
|
---|
| 6 | /* eslint-disable max-len */
|
---|
| 7 | /**
|
---|
| 8 | * Checks if value is valid `Date` object.
|
---|
| 9 | *
|
---|
| 10 | * @func isValidDate
|
---|
| 11 | * @memberOf RA
|
---|
| 12 | * @since {@link https://char0n.github.io/ramda-adjunct/1.8.0|v1.8.0}
|
---|
| 13 | * @category Type
|
---|
| 14 | * @sig * -> Boolean
|
---|
| 15 | * @param {*} val The value to test
|
---|
| 16 | * @return {boolean}
|
---|
| 17 | * @see {@link RA.isDate|isDate}, {@link RA.isNotDate|isNotDate}, {@link RA.isNotValidDate|isNotValidDate}
|
---|
| 18 | * @example
|
---|
| 19 | *
|
---|
| 20 | * RA.isValidDate(new Date()); //=> true
|
---|
| 21 | * RA.isValidDate(new Date('a')); //=> false
|
---|
| 22 | */
|
---|
| 23 | /* eslint-enable max-len */
|
---|
| 24 | const isValidDate = curryN(
|
---|
| 25 | 1,
|
---|
| 26 | both(isDate, pipe(invoker(0, 'getTime'), isNotNaN))
|
---|
| 27 | );
|
---|
| 28 |
|
---|
| 29 | export default isValidDate;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.