Skip to content

Commit

Permalink
0.7.8 - add isJSON/isJson and isUUID/isUuid aliases and add CHANGELOG.md
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanCannon committed May 19, 2023
1 parent 90b7c2b commit 5197f4a
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 16 deletions.
119 changes: 119 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Changelog

All notable changes to this project will be documented in this file.

Changes not listed here (skipped semver) are typically dependency updates or README fixes.


## [0.7.8] - 2023-05-19

### Added

- (string) `isUUID` / `isUuid` alias
- (string) `isJSON` / `isJson` alias

## [0.7.7] - 2023-03-30

### Added

- (string) `isUuid`


## [0.7.5] - 2021-11-03

### Added

- (string) `isMySqlTimestamp`


## [0.7.0] - 2017-12-10

### Added

- (primitive) `isBoolean`


## [0.5.0] - 2017-11-19

### Added

- babel support and point main package to dist es5 version


## [0.4.0] - 2017-08-24

### Added

- (string) `isTimestamp`


## [0.3.0] - 2017-08-11

### Added

- (number) `isNumeric`
- (string) `isNumericString`


## [0.2.2] - 2017-02-22

### Added

- (string) `isStringOfLengthBetween`

### Fixed

- (number) `isCalendarMonth`
- (number) `isCalendarMonthZeroBased`


## [0.2.1] - 2017-02-22

### Changed

- (number) optimize `isNumberBetween`


## [0.2.0] - 2017-02-22

### Added

- (object) `isObject`
- (object) `isObjectContaining`
- (object) `isObjectAbsent`
- (object) `isObjectMatching`
- (object) `isObjectExtending`
- (object) `isObjectSatisfying`

### Changed

- update to ES6


## [0.1.0] - 2015-12-31

### Added

- (string) `isJSON`


## [0.0.9] - 2015-07-08

### Added

- (number) `isNumericBoolean`


## [0.0.5] - 2015-07-07

### Added

- (number) `numberIsOneOf`
- (string) `stringIsOneOf`


## [0.0.1] - 2015-07-07

### Added

- Initial commit
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ const validateUserOrThrow = V.isObjectOf(userType);
validateUserOrThrow(userType, user);
```

# Interface
- [Strings](#strings)
- [Numbers](#numbers)
- [Arrays](#arrays)
- [Objects](#objects)
- [Primitives](#primitives)

## Strings

### isString
Expand Down Expand Up @@ -187,19 +194,29 @@ expect(prr.isNumericString('asd123asd')).toBe(false);
```

---
### isJSON
### isJSON / isJson
String → Boolean
```
expect(prr.isJSON('foo')).toBe(false);
expect(prr.isJSON('{foo:"bar"}')).toBe(false);
expect(prr.isJSON('{}')).toBe(true);
expect(prr.isJSON('{"foo":"bar"}')).toBe(true);
expect(prr.isJson('foo')).toBe(false);
expect(prr.isJson('{foo:"bar"}')).toBe(false);
expect(prr.isJson('{}')).toBe(true);
expect(prr.isJson('{"foo":"bar"}')).toBe(true);
```

---
### isUuid
### isUUID / isUuid
String → Boolean
```
expect(prr.isUUID('foo')).toBe(false);
expect(prr.isUUID(123)).toBe(false);
expect(prr.isUUID('cd17c371-9468-963b-f3e0bf05e70e')).toBe(false);
expect(prr.isUUID('cd17c371-9468-4baa-963b-f3e0bf05e70e')).toBe(true);
expect(prr.isUuid('foo')).toBe(false);
expect(prr.isUuid(123)).toBe(false);
expect(prr.isUuid('cd17c371-9468-963b-f3e0bf05e70e')).toBe(false);
Expand Down
4 changes: 2 additions & 2 deletions lib/predicates/arrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ const R = require('ramda'),

module.exports = {
isArray : R.is(Array),
isArrayOfLength : __.ofLength(Array, 'identical'),
isArrayOfLength : __.ofLength(Array, 'equals'),
isArrayOfLengthAtLeast : __.ofLength(Array, 'gte'),
isArrayOfLengthAtMost : __.ofLength(Array, 'lte'),
isArrayLongerThan : __.ofLength(Array, 'gt'),
isArrayShorterThan : __.ofLength(Array, 'lt'),
isArrayContaining : R.contains(R.__),
isArrayContaining : R.includes(R.__),
isEmptyArray : R.allPass([R.is(Array), R.isEmpty])
};
4 changes: 2 additions & 2 deletions lib/predicates/numbers.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const isNumberBetweenInclusive = R.curry((min, max, n) => {
});

const numberIsOneOf = R.curry((selectionArr, num) => {
return R.allPass([R.is(Number), R.contains(R.__, selectionArr)])(num);
return R.allPass([R.is(Number), R.includes(R.__, selectionArr)])(num);
});

const isNumber = R.is(Number),
Expand All @@ -25,7 +25,7 @@ const isNumber = R.is(Number),
isEvenNumber = __.modTwoEq(0),
isOddNumber = __.modTwoEq(1),
isNumeric = v => !isNaN(parseInt(v, 10)),
isNumericBoolean = R.contains(R.__, [0, 1]);
isNumericBoolean = R.includes(R.__, [0, 1]);

module.exports = {
isNumber,
Expand Down
10 changes: 6 additions & 4 deletions lib/predicates/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const R = require('ramda'),
__ = require('./_private.js');

const isString = R.is(String),
isStringOfLength = __.ofLength(String, 'identical'),
isStringOfLength = __.ofLength(String, 'equals'),
isStringOfLengthAtLeast = __.ofLength(String, 'gte'),
isStringOfLengthAtMost = __.ofLength(String, 'lte'),
isStringLongerThan = __.ofLength(String, 'gt'),
Expand All @@ -19,7 +19,7 @@ const isStringMatching = R.curry((pattern, str) => {
});

const stringIsOneOf = R.curry((selectionArr, str) => {
return R.allPass([R.is(String), R.contains(R.__, selectionArr)])(str);
return R.allPass([R.is(String), R.includes(R.__, selectionArr)])(str);
});

const isStringOfLengthBetween = R.curry((min, max, str) => {
Expand All @@ -38,7 +38,7 @@ const isTimestamp = R.test(/(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([

const isMySqlTimestamp = R.test(/^([1-2][0-9]{3})-([0-1][0-9])-([0-3][0-9])(?:( [0-2][0-9]):([0-5][0-9]):([0-5][0-9]))?$/);

const isUuid = R.test(/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi);
const isUUID = R.test(/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi);

const isJSON = (str) => {
try {
Expand Down Expand Up @@ -66,5 +66,7 @@ module.exports = {
isMySqlTimestamp,
isEmail,
isJSON,
isUuid
isUUID,
isJson : isJSON,
isUuid : isUUID
};
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "prettycats",
"version": "0.7.7",
"version": "0.7.8",
"description": "Helpful, common, and curried predicates library built on Ramda.",
"main": "dist/prettycats.js",
"dependencies": {
"ramda": "^0.27.x"
"ramda": "^0.29.x"
},
"devDependencies": {
"@babel/cli": "^7.6.4",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2435,10 +2435,10 @@ qs@~6.5.2:
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36"
integrity sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==

ramda@^0.27.x:
version "0.27.1"
resolved "https://registry.yarnpkg.com/ramda/-/ramda-0.27.1.tgz#66fc2df3ef873874ffc2da6aa8984658abacf5c9"
integrity sha512-PgIdVpn5y5Yns8vqb8FzBUEYn98V3xcPgawAkkgj0YJ0qDsnHCiNmZYfOGMgOvoB0eWFLpYbhxUR3mxfDIMvpw==
ramda@^0.29.x:
version "0.29.0"
resolved "https://registry.yarnpkg.com/ramda/-/ramda-0.29.0.tgz#fbbb67a740a754c8a4cbb41e2a6e0eb8507f55fb"
integrity sha512-BBea6L67bYLtdbOqfp8f58fPMqEwx0doL+pAi8TZyp2YWz8R9G8z9x75CZI8W+ftqhFHCpEX2cRnUUXK130iKA==

read-pkg-up@^4.0.0:
version "4.0.0"
Expand Down

0 comments on commit 5197f4a

Please sign in to comment.