Skip to content

Commit

Permalink
Merge pull request #42 from Psychopoulet/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Psychopoulet committed Oct 14, 2020
2 parents 147b285 + cfda597 commit 683e657
Show file tree
Hide file tree
Showing 5 changed files with 313 additions and 430 deletions.
11 changes: 5 additions & 6 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
const ensureDataObject = require(join(__dirname, "ensureDataObject.js"));
const ensureDataSpecific = require(join(__dirname, "ensureDataSpecific.js"));
const ensureDataBasic = require(join(__dirname, "ensureDataBasic.js"));
const { patternEmail, patternUrl } = require(join(__dirname, "patterns.js"));
const { patternEmail, patternUrl, patternIPV4, patternIPV6 } = require(join(__dirname, "patterns.js"));

// consts

Expand Down Expand Up @@ -217,14 +217,13 @@ module.exports = class NodeContainerPattern extends Map {

const fullKey = !isEmptyString(previousKeys) ? previousKeys + this.recursionSeparator + key : key;

const documentation = this.documentations[fullKey] ? this.documentations[fullKey] : "";

result[key] = {
documentation,
"documentation": this.documentations[fullKey] ? this.documentations[fullKey] : "",
"fullkey": fullKey,
"min": isDefined(this.mins[fullKey]) ? this.mins[fullKey] : null,
"max": isDefined(this.maxs[fullKey]) ? this.maxs[fullKey] : null,
"limits": isArray(this.limits[fullKey]) ? this.limits[fullKey] : null,
"regex": isDefined(this.regexs[fullKey]) ? this.regexs[fullKey] : null,
"type": isNotEmptyString(this.skeletons[fullKey]) ? this.skeletons[fullKey] : getTypeValue(value)
};

Expand Down Expand Up @@ -650,12 +649,12 @@ module.exports = class NodeContainerPattern extends Map {

// 0.0.0.0 -> 256.256.256.256
else if ("ipv4" === skeleton) {
this.min(key, 7).max(key, 15);
this.min(key, 7).max(key, 15).regex(key, patternIPV4);
}

// ::::::: -> ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
else if ("ipv6" === skeleton) {
this.min(key, 7).max(key, 39);
this.min(key, 7).max(key, 39).regex(key, patternIPV6);
}

// www.s.tv, ftp://s.tv, https://thisisatest.com?req=sort_desc
Expand Down
4 changes: 3 additions & 1 deletion lib/patterns.js

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": "node-containerpattern",
"version": "1.2.1",
"version": "1.3.0",
"description": "A 'Container pattern' object for a clean global use of data.",
"main": "lib/main.js",
"typings": "lib/index.d.ts",
Expand Down Expand Up @@ -44,10 +44,10 @@
},
"dependencies": {},
"devDependencies": {
"@types/node": "14.11.5",
"@types/node": "14.11.8",
"check-version-modules": "1.3.0",
"coveralls": "3.1.0",
"eslint": "7.10.0",
"eslint": "7.11.0",
"husky": "4.3.0",
"mocha": "8.1.3",
"nyc": "15.1.0"
Expand Down
3 changes: 3 additions & 0 deletions test/1_validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ describe("validators", () => {
strictEqual(Validators.isIPV4(0), false, "isIPV4 result test is invalid");
strictEqual(Validators.isIPV4(""), false, "isIPV4 result test is invalid");
strictEqual(Validators.isIPV4("test"), false, "isIPV4 result test is invalid");
strictEqual(Validators.isIPV4("255.255.255.256"), false, "isIPV4 result test is invalid");
strictEqual(Validators.isIPV4("0.0.0.e"), false, "isIPV4 result test is invalid");
strictEqual(Validators.isIPV4("0.0.0.0"), true, "isIPV4 result test is invalid");
strictEqual(Validators.isIPV4("127.0.0.1"), true, "isIPV4 result test is invalid");
});

Expand Down
Loading

0 comments on commit 683e657

Please sign in to comment.