Skip to content

Commit

Permalink
Merge pull request #248 from hckrnews/feature/snyk
Browse files Browse the repository at this point in the history
Update dependencies
  • Loading branch information
w3nl authored Dec 18, 2023
2 parents 8489ef1 + caac7f6 commit 971830d
Show file tree
Hide file tree
Showing 6 changed files with 187 additions and 163 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.4.0
20.10.0
16 changes: 16 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"checkJs": true,
"target": "ESNext",
"module": "NodeNext",
"moduleResolution": "nodenext",
"rootDirs": [
"src"
],
"resolveJsonModule": true
},
"exclude": [
"node_modules",
"**/node_modules/*"
]
}
311 changes: 156 additions & 155 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hckrnews/validator",
"version": "8.0.12",
"version": "8.0.13",
"description": "Object validator",
"main": "dist/validator.umd.cjs",
"type": "module",
Expand Down
17 changes: 12 additions & 5 deletions src/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,25 @@ class Validator {
return fieldType;
}

/**
* Filter the items.
* @param {string} fieldNameRaw
* @param {any} fieldType
* @param {object} item
* @return {boolean}
*/
filterItems(fieldNameRaw, fieldType, item) {
if (!item) {
return false;
}

let fieldName = fieldNameRaw;

if (fieldNameRaw.substr(0, 1) === '?') {
fieldName = fieldNameRaw.substr(1);
if (fieldNameRaw.startsWith('?')) {
fieldName = fieldNameRaw.slice(1);
}

if (fieldNameRaw.substr(-1, 1) === '?') {
if (fieldNameRaw.endsWith('?')) {
fieldName = fieldNameRaw.slice(0, -1);
}

Expand Down Expand Up @@ -141,7 +148,7 @@ class Validator {
/**
* Validate an array
*
* @param {mixed} value
* @param {any} value
* @param {string} fieldType
*
* @return {boolean}
Expand All @@ -153,7 +160,7 @@ class Validator {
/**
* Validate an object
*
* @param {mixed} value
* @param {any} value
* @param {string} fieldType
*
* @return {boolean}
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/validator.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'node:test';
import assert from 'assert';
import assert from 'node:assert';
import { Validator } from '../../src/validator.js';
import barSchema from '../../src/schemas/bar.js';
import carSchema from '../../src/schemas/car.js';
Expand Down

0 comments on commit 971830d

Please sign in to comment.