New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

uniforms-bridge-simple-schema-2

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uniforms-bridge-simple-schema-2 - npm Package Compare versions

Comparing version 3.0.0-rc.0 to 3.0.0-rc.1

23

es5/SimpleSchema2Bridge.d.ts

@@ -0,14 +1,15 @@

import SimpleSchema from 'simpl-schema';
import { Bridge } from 'uniforms';
export default class SimpleSchema2Bridge extends Bridge {
schema: any;
constructor(schema: any);
getError(name: any, error: any): any;
getErrorMessage(name: any, error: any): any;
getErrorMessages(error: any): any;
getField(name: any): any;
getInitialValue(name: any, props?: any): any;
getProps(name: any, props?: any): any;
getSubfields(name?: string): any;
getType(name: any): any;
getValidator(options?: any): (model: any) => any;
schema: SimpleSchema;
constructor(schema: SimpleSchema);
getError(name: string, error: any): any;
getErrorMessage(name: string, error: any): string;
getErrorMessages(error: any): any[];
getField(name: string): any;
getInitialValue(name: string, props?: Record<string, any>): any;
getProps(name: string, props?: Record<string, any>): any;
getSubfields(name?: string): any[];
getType(name: string): any;
getValidator(options?: Record<string, any>): (model: Record<string, any>) => any;
}

@@ -21,10 +21,9 @@ "use strict";

SimpleSchema2Bridge.prototype.getError = function (name, error) {
return ((error &&
error.details &&
error.details.find &&
error.details.find(function (error) { return error.name === name; })) ||
null);
var _a, _b;
// FIXME: Correct type for `error`.
return ((_b = (_a = error === null || error === void 0 ? void 0 : error.details) === null || _a === void 0 ? void 0 : _a.find) === null || _b === void 0 ? void 0 : _b.call(_a, function (error) { return error.name === name; })) || null;
};
SimpleSchema2Bridge.prototype.getErrorMessage = function (name, error) {
var scopedError = this.getError(name, error);
// @ts-ignore: `messageForError` has incorrect typing.
return !scopedError ? '' : this.schema.messageForError(scopedError);

@@ -36,3 +35,7 @@ };

if (Array.isArray(error.details)) {
return error.details.map(function (error) { return _this.schema.messageForError(error); });
// FIXME: Correct type for `error`.
return error.details.map(function (error) {
// @ts-ignore: `messageForError` has incorrect typing.
return _this.schema.messageForError(error);
});
}

@@ -128,2 +131,3 @@ if (error.message) {

SimpleSchema2Bridge.prototype.getSubfields = function (name) {
// @ts-ignore: Typing for `_makeGeneric` is missing.
return this.schema.objectKeys(simpl_schema_1.default._makeGeneric(name));

@@ -141,2 +145,3 @@ };

};
// TODO: `ValidationOption` is not exported.
SimpleSchema2Bridge.prototype.getValidator = function (options) {

@@ -143,0 +148,0 @@ if (options === void 0) { options = { clean: true, mutate: true }; }

@@ -0,14 +1,15 @@

import SimpleSchema from 'simpl-schema';
import { Bridge } from 'uniforms';
export default class SimpleSchema2Bridge extends Bridge {
schema: any;
constructor(schema: any);
getError(name: any, error: any): any;
getErrorMessage(name: any, error: any): any;
getErrorMessages(error: any): any;
getField(name: any): any;
getInitialValue(name: any, props?: any): any;
getProps(name: any, props?: any): any;
getSubfields(name?: string): any;
getType(name: any): any;
getValidator(options?: any): (model: any) => any;
schema: SimpleSchema;
constructor(schema: SimpleSchema);
getError(name: string, error: any): any;
getErrorMessage(name: string, error: any): string;
getErrorMessages(error: any): any[];
getField(name: string): any;
getInitialValue(name: string, props?: Record<string, any>): any;
getProps(name: string, props?: Record<string, any>): any;
getSubfields(name?: string): any[];
getType(name: string): any;
getValidator(options?: Record<string, any>): (model: Record<string, any>) => any;
}

@@ -17,10 +17,9 @@ import { __rest } from "tslib";

getError(name, error) {
return ((error &&
error.details &&
error.details.find &&
error.details.find(error => error.name === name)) ||
null);
var _a, _b;
// FIXME: Correct type for `error`.
return ((_b = (_a = error === null || error === void 0 ? void 0 : error.details) === null || _a === void 0 ? void 0 : _a.find) === null || _b === void 0 ? void 0 : _b.call(_a, (error) => error.name === name)) || null;
}
getErrorMessage(name, error) {
const scopedError = this.getError(name, error);
// @ts-ignore: `messageForError` has incorrect typing.
return !scopedError ? '' : this.schema.messageForError(scopedError);

@@ -31,3 +30,6 @@ }

if (Array.isArray(error.details)) {
return error.details.map(error => this.schema.messageForError(error));
// FIXME: Correct type for `error`.
return error.details.map(error =>
// @ts-ignore: `messageForError` has incorrect typing.
this.schema.messageForError(error));
}

@@ -110,6 +112,6 @@ if (error.message) {

if (!Array.isArray(options)) {
field = Object.assign(Object.assign({}, field), { transform: value => options[value], allowedValues: Object.keys(options) });
field = Object.assign(Object.assign({}, field), { transform: (value) => options[value], allowedValues: Object.keys(options) });
}
else {
field = Object.assign(Object.assign({}, field), { transform: value => options.find(option => option.value === value).label, allowedValues: options.map(option => option.value) });
field = Object.assign(Object.assign({}, field), { transform: (value) => options.find(option => option.value === value).label, allowedValues: options.map(option => option.value) });
}

@@ -120,2 +122,3 @@ }

getSubfields(name) {
// @ts-ignore: Typing for `_makeGeneric` is missing.
return this.schema.objectKeys(SimpleSchema._makeGeneric(name));

@@ -133,5 +136,6 @@ }

}
// TODO: `ValidationOption` is not exported.
getValidator(options = { clean: true, mutate: true }) {
const validator = this.schema.validator(options);
return model => {
return (model) => {
try {

@@ -138,0 +142,0 @@ // Clean mutate its argument, even if mutate is false.

{
"name": "uniforms-bridge-simple-schema-2",
"version": "3.0.0-rc.0",
"version": "3.0.0-rc.1",
"license": "MIT",

@@ -31,5 +31,5 @@ "main": "es5/index.js",

"tslib": "^1.10.0",
"uniforms": "^3.0.0-rc.0"
"uniforms": "^3.0.0-rc.1"
},
"gitHead": "446ab9bd202f14644854afc628bd68b0eef0ecef"
"gitHead": "38efcda044cbb7001e2c989eb5eeeb592fb284d7"
}

@@ -8,9 +8,5 @@ import SimpleSchema from 'simpl-schema';

export default class SimpleSchema2Bridge extends Bridge {
schema: any;
constructor(schema) {
constructor(public schema: SimpleSchema) {
super();
this.schema = schema;
// Memoize for performance and referential equality.

@@ -22,21 +18,21 @@ this.getField = memoize(this.getField);

getError(name, error) {
return (
(error &&
error.details &&
error.details.find &&
error.details.find(error => error.name === name)) ||
null
);
getError(name: string, error: any) {
// FIXME: Correct type for `error`.
return error?.details?.find?.((error: any) => error.name === name) || null;
}
getErrorMessage(name, error) {
getErrorMessage(name: string, error: any) {
const scopedError = this.getError(name, error);
// @ts-ignore: `messageForError` has incorrect typing.
return !scopedError ? '' : this.schema.messageForError(scopedError);
}
getErrorMessages(error) {
getErrorMessages(error: any) {
if (error) {
if (Array.isArray(error.details)) {
return error.details.map(error => this.schema.messageForError(error));
// FIXME: Correct type for `error`.
return (error.details as any[]).map(error =>
// @ts-ignore: `messageForError` has incorrect typing.
this.schema.messageForError(error),
);
}

@@ -56,3 +52,3 @@

getField(name) {
getField(name: string) {
const definition = this.schema.getDefinition(name);

@@ -83,3 +79,3 @@

getInitialValue(name, props: any = {}) {
getInitialValue(name: string, props: Record<string, any> = {}): any {
const field = this.getField(name);

@@ -102,3 +98,3 @@

// eslint-disable-next-line complexity
getProps(name, props: any = {}) {
getProps(name: string, props: Record<string, any> = {}) {
// Type should be omitted.

@@ -144,3 +140,3 @@ // eslint-disable-next-line no-unused-vars, prefer-const

...field,
transform: value => options[value],
transform: (value: any) => options[value],
allowedValues: Object.keys(options),

@@ -151,4 +147,4 @@ };

...field,
transform: value =>
options.find(option => option.value === value).label,
transform: (value: any) =>
(options as any[]).find(option => option.value === value).label,
allowedValues: options.map(option => option.value),

@@ -163,6 +159,7 @@ };

getSubfields(name?: string) {
// @ts-ignore: Typing for `_makeGeneric` is missing.
return this.schema.objectKeys(SimpleSchema._makeGeneric(name));
}
getType(name) {
getType(name: string) {
const type = this.getField(name).type;

@@ -181,5 +178,6 @@

getValidator(options = { clean: true, mutate: true } as any) {
// TODO: `ValidationOption` is not exported.
getValidator(options: Record<string, any> = { clean: true, mutate: true }) {
const validator = this.schema.validator(options);
return model => {
return (model: Record<string, any>) => {
try {

@@ -186,0 +184,0 @@ // Clean mutate its argument, even if mutate is false.

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc