@byll/validated
Advanced tools
Comparing version 1.10.0 to 1.11.0
@@ -9,2 +9,7 @@ export declare const factories: any; | ||
export declare function validate(value: any, validators: Validator[]): string[]; | ||
/** | ||
* @param prototype: validator class | ||
* @returns list of all possible keys on the validator | ||
*/ | ||
export declare function getKeys(prototype: any): string[]; | ||
export declare abstract class Validated { | ||
@@ -11,0 +16,0 @@ constructor(raw: any, options?: { |
@@ -260,2 +260,20 @@ "use strict"; | ||
exports.validate = validate; | ||
/** | ||
* @param prototype: validator class | ||
* @returns list of all possible keys on the validator | ||
*/ | ||
function getKeys(prototype) { | ||
var result = new Set(); | ||
while ((prototype = Object.getPrototypeOf(prototype)) && prototype !== Validated.prototype) { | ||
if (!keys.has(prototype.constructor)) { | ||
continue; | ||
} | ||
var subset = keys.get(prototype.constructor); | ||
subset.forEach(function (_validators, key) { | ||
result.add(key); | ||
}); | ||
} | ||
return Array.from(result); | ||
} | ||
exports.getKeys = getKeys; | ||
var Validated = (function () { | ||
@@ -262,0 +280,0 @@ function Validated(raw, options) { |
{ | ||
"name": "@byll/validated", | ||
"version": "1.10.0", | ||
"version": "1.11.0", | ||
"main": "lib/src/index.js", | ||
@@ -5,0 +5,0 @@ "typings": "lib/src/index", |
@@ -227,2 +227,18 @@ import { isValidDecimalString } from './helpers/isValidDecimalString' | ||
/** | ||
* @param prototype: validator class | ||
* @returns list of all possible keys on the validator | ||
*/ | ||
export function getKeys (prototype): string[] { | ||
const result = new Set<string>() | ||
while ((prototype = Object.getPrototypeOf(prototype)) && prototype !== Validated.prototype) { | ||
if (!keys.has(prototype.constructor)) { continue } | ||
const subset = keys.get(prototype.constructor)! | ||
subset.forEach((_validators, key) => { | ||
result.add(key) | ||
}) | ||
} | ||
return Array.from(result) | ||
} | ||
export abstract class Validated { | ||
@@ -229,0 +245,0 @@ constructor(raw, options?: { Error?: new(details) => any, parse?: 'json', allowAdditionalKeys?: boolean }) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
78492
1172