You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

schema-to-yup

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.12.3 to 1.12.4

src/config.js

2

package.json
{
"name": "schema-to-yup",
"version": "1.12.3",
"version": "1.12.4",
"publishConfig": {

@@ -5,0 +5,0 @@ "access": "public"

@@ -126,2 +126,4 @@ <!-- vscode-markdown-toc -->

You can use the `YupBuilderConfig` and `TypeHandlerConfig` types and classes to facilitate building up the `config` object to pass to the `YupBuilder`.
## 5. <a name='BuildandSamplerun'></a>Build and Sample run

@@ -757,3 +759,3 @@

const oneOfConditional = (th) => {
let { config, parentNode, isObject, value, key } = th;
let { config, parentNode, isObjectType, value, key } = th;
// optionally set custom errMsg

@@ -766,3 +768,3 @@ const oneOfConstraints = value;

for (let constraint in oneOfConstraints) {
if (!isObject(constraint)) {
if (!isObjectType(constraint)) {
return value === constraint;

@@ -769,0 +771,0 @@ }

class Loggable {
constructor(config = {}) {
this.config = config;
const { log, error } = config;
const { log, error } = config;
const enable = config.enable || {};
if (config.logging === true) {
enable.log = true
enable.log = true;
}
if (config.logging === false) {
enable.log = false
enable.log = false;
}

@@ -21,3 +21,3 @@ this.enable = enable;

if (this.enable.error === false) return;
if (!this.err) return
if (!this.err) return;
values && values.length ? this.err(errMsg, ...values) : this.err(errMsg);

@@ -34,27 +34,31 @@ throw errMsg;

if (!this.enable.log) return;
if (!this.log) return
const matchTypeList = this.config.logTypes || []
if (!matchTypeList.length) return
const found = matchTypeList.find(matchType => this.type === matchType)
if (!found) return
logInfo(name, ...values)
if (!this.log) return;
const matchTypeList = this.config.logTypes || [];
if (!matchTypeList.length) return;
const found = matchTypeList.find((matchType) => this.type === matchType);
if (!found) return;
logInfo(name, ...values);
}
logDetails(label, idObj, ...values) {
const matchIdList = this.config.logDetailed || []
if (!matchIdList.length) return
const found = matchIdList.find(matchIds => {
if (matchIds.key && idObj.key !== matchIds.key) return false
if (matchIds.constraintName && idObj.constraintName !== matchIds.constraintName) return false
if (matchIds.propName && idObj.propName !== matchIds.propName) return false
if (matchIds.method && idObj.method !== matchIds.method) return false
return true
})
found && this.logInfo(label, idObj, ...values)
const matchIdList = this.config.logDetailed || [];
if (!matchIdList.length) return;
const found = matchIdList.find((matchIds) => {
if (matchIds.key && idObj.key !== matchIds.key) return false;
if (
matchIds.constraintName &&
idObj.constraintName !== matchIds.constraintName
)
return false;
if (matchIds.propName && idObj.propName !== matchIds.propName)
return false;
if (matchIds.method && idObj.method !== matchIds.method) return false;
return true;
});
found && this.logInfo(label, idObj, ...values);
}
logInfo(name, ...values) {
if (!this.enable.log) return;
if (!this.log) return
if (!this.log) return;
values && values.length ? this.log(name, ...values) : this.log(name);

@@ -61,0 +65,0 @@ }

@@ -60,2 +60,4 @@ export class YupMixed extends Base {

createSchemaEntry(): any;
preConvert(): void;
postConvert(): void;
convert(): YupMixed;

@@ -78,2 +80,4 @@ apply(fnName: any, ...fnArgs: any[]): YupMixed;

oneOf(): YupMixed;
oneOfConditional(): void;
notOneOfConditional(): void;
logDetailed(label: any, idObj: any, ...values: any[]): void;

@@ -80,0 +84,0 @@ get notOneOfValues(): any;

@@ -1,8 +0,2 @@

export function buildYup(schema: any, config?: {}, parentNode?: any): yup.ObjectSchema<{
[x: string]: yup.AnySchema<any, any, any> | import("yup/lib/Reference").default<unknown> | import("yup/lib/Lazy").default<any, any>;
}, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<{
[x: string]: yup.AnySchema<any, any, any> | import("yup/lib/Reference").default<unknown> | import("yup/lib/Lazy").default<any, any>;
}>, import("yup/lib/object").AssertsShape<{
[x: string]: yup.AnySchema<any, any, any> | import("yup/lib/Reference").default<unknown> | import("yup/lib/Lazy").default<any, any>;
}>>;
export function buildYup(schema: any, config?: {}, parentNode?: any): yup.ObjectSchema<any, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<any>, import("yup/lib/object").AssertsShape<any>>;
export class YupBuilder extends Base {

@@ -17,3 +11,3 @@ constructor(schema: any, config?: {}, parentNode?: any);

required: any;
shapeConfig: {};
shapeConfig: any;
validSchema: boolean;

@@ -27,9 +21,3 @@ get validator(): typeof yup;

getName(obj: any): any;
get yupSchema(): yup.ObjectSchema<{
[x: string]: yup.AnySchema<any, any, any> | import("yup/lib/Reference").default<unknown> | import("yup/lib/Lazy").default<any, any>;
}, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<{
[x: string]: yup.AnySchema<any, any, any> | import("yup/lib/Reference").default<unknown> | import("yup/lib/Lazy").default<any, any>;
}>, import("yup/lib/object").AssertsShape<{
[x: string]: yup.AnySchema<any, any, any> | import("yup/lib/Reference").default<unknown> | import("yup/lib/Lazy").default<any, any>;
}>>;
get yupSchema(): yup.ObjectSchema<any, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<any>, import("yup/lib/object").AssertsShape<any>>;
buildProperties(): {};

@@ -41,4 +29,4 @@ getRequiredPropsList(): any[];

isRequired(value: any): any;
propsToShape(opts?: {}): {};
objPropsShape: {};
propsToShape(opts?: {}): any;
objPropsShape: any;
addPropsShape: any;

@@ -48,3 +36,4 @@ additionalPropsToShape(shape: any, opts?: {}): any;

name: any;
}): {};
}): any;
reducePropToShape(acc: any, key: any, prop: any): any;
propToYupSchemaEntry({ name, key, value }: {

@@ -51,0 +40,0 @@ name: any;

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc