Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vinejs/compiler

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vinejs/compiler - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

42

build/src/scripts/define_inline_functions.js
export function defineInlineFunctions(options) {
return `function report(message, rule, ctx, args) {
ctx.isValid = false;
errorReporter.report(messagesProvider.getMessage(message, rule, ctx, args), rule, ctx, args);
return `function report(message, rule, field, args) {
field.isValid = false;
errorReporter.report(messagesProvider.getMessage(message, rule, field, args), rule, field, args);
};
function defineValue(value, ctx) {
function defineValue(value, field) {
${options.convertEmptyStringsToNull ? `if (value === '') { value = null; }` : ''}
ctx.value = value;
ctx.isDefined = value !== undefined && value !== null;
return ctx;
field.value = value;
field.isDefined = value !== undefined && value !== null;
return field;
};
function ensureExists(ctx) {
if (ctx.value === undefined || ctx.value === null) {
ctx.report(REQUIRED, 'required', ctx);
function ensureExists(field) {
if (field.value === undefined || field.value === null) {
field.report(REQUIRED, 'required', field);
return false;

@@ -19,5 +19,5 @@ }

};
function ensureIsDefined(ctx) {
if (ctx.value === undefined) {
ctx.report(REQUIRED, 'required', ctx);
function ensureIsDefined(field) {
if (field.value === undefined) {
field.report(REQUIRED, 'required', field);
return false;

@@ -27,20 +27,20 @@ }

};
function ensureIsObject(ctx) {
if (!ctx.isDefined) {
function ensureIsObject(field) {
if (!field.isDefined) {
return false;
}
if (typeof ctx.value == 'object' && !Array.isArray(ctx.value)) {
if (typeof field.value == 'object' && !Array.isArray(field.value)) {
return true;
}
ctx.report(NOT_AN_OBJECT, 'object', ctx);
field.report(NOT_AN_OBJECT, 'object', field);
return false;
};
function ensureIsArray(ctx) {
if (!ctx.isDefined) {
function ensureIsArray(field) {
if (!field.isDefined) {
return false;
}
if (Array.isArray(ctx.value)) {
if (Array.isArray(field.value)) {
return true;
}
ctx.report(NOT_AN_ARRAY, 'array', ctx);
field.report(NOT_AN_ARRAY, 'array', field);
return false;

@@ -47,0 +47,0 @@ };

@@ -15,3 +15,3 @@ export type RefIdentifier = `ref://${number}`;

meta: Record<string, any>;
mutate(newValue: any, ctx: FieldContext): void;
mutate(newValue: any, field: FieldContext): void;
report: ErrorReporterContract['report'];

@@ -26,8 +26,8 @@ isValid: boolean;

export type ValidationRule = {
validator(value: unknown, options: any, ctx: FieldContext): any;
validator(value: unknown, options: any, field: FieldContext): any;
options?: any;
};
export type ParseFn = (value: unknown) => any;
export type TransformFn<Input, Output> = (value: Input, ctx: FieldContext) => Output;
export type ConditionalFn<Input> = (value: Input, ctx: FieldContext) => boolean;
export type TransformFn<Input, Output> = (value: Input, field: FieldContext) => Output;
export type ConditionalFn<Input> = (value: Input, field: FieldContext) => boolean;
export type ValidationNode = {

@@ -117,6 +117,6 @@ ruleFnId: RefIdentifier;

createError(): Error;
report(message: string, rule: string, ctx: FieldContext, args?: Record<string, any>): any;
report(message: string, rule: string, field: FieldContext, args?: Record<string, any>): any;
}
export interface MessagesProviderContact {
getMessage(defaultMessage: string, rule: string, ctx: FieldContext, args?: Record<string, any>): string;
getMessage(defaultMessage: string, rule: string, field: FieldContext, args?: Record<string, any>): string;
}

@@ -123,0 +123,0 @@ export type CompilerOptions = {

{
"name": "@vinejs/compiler",
"version": "2.0.0",
"version": "2.0.1",
"description": "Low level compiler for VineJS validator",

@@ -5,0 +5,0 @@ "type": "module",

@@ -15,15 +15,15 @@ /*

export function defineInlineFunctions(options: { convertEmptyStringsToNull: boolean }) {
return `function report(message, rule, ctx, args) {
ctx.isValid = false;
errorReporter.report(messagesProvider.getMessage(message, rule, ctx, args), rule, ctx, args);
return `function report(message, rule, field, args) {
field.isValid = false;
errorReporter.report(messagesProvider.getMessage(message, rule, field, args), rule, field, args);
};
function defineValue(value, ctx) {
function defineValue(value, field) {
${options.convertEmptyStringsToNull ? `if (value === '') { value = null; }` : ''}
ctx.value = value;
ctx.isDefined = value !== undefined && value !== null;
return ctx;
field.value = value;
field.isDefined = value !== undefined && value !== null;
return field;
};
function ensureExists(ctx) {
if (ctx.value === undefined || ctx.value === null) {
ctx.report(REQUIRED, 'required', ctx);
function ensureExists(field) {
if (field.value === undefined || field.value === null) {
field.report(REQUIRED, 'required', field);
return false;

@@ -33,5 +33,5 @@ }

};
function ensureIsDefined(ctx) {
if (ctx.value === undefined) {
ctx.report(REQUIRED, 'required', ctx);
function ensureIsDefined(field) {
if (field.value === undefined) {
field.report(REQUIRED, 'required', field);
return false;

@@ -41,20 +41,20 @@ }

};
function ensureIsObject(ctx) {
if (!ctx.isDefined) {
function ensureIsObject(field) {
if (!field.isDefined) {
return false;
}
if (typeof ctx.value == 'object' && !Array.isArray(ctx.value)) {
if (typeof field.value == 'object' && !Array.isArray(field.value)) {
return true;
}
ctx.report(NOT_AN_OBJECT, 'object', ctx);
field.report(NOT_AN_OBJECT, 'object', field);
return false;
};
function ensureIsArray(ctx) {
if (!ctx.isDefined) {
function ensureIsArray(field) {
if (!field.isDefined) {
return false;
}
if (Array.isArray(ctx.value)) {
if (Array.isArray(field.value)) {
return true;
}
ctx.report(NOT_AN_ARRAY, 'array', ctx);
field.report(NOT_AN_ARRAY, 'array', field);
return false;

@@ -61,0 +61,0 @@ };

@@ -80,3 +80,3 @@ /*

*/
mutate(newValue: any, ctx: FieldContext): void
mutate(newValue: any, field: FieldContext): void

@@ -132,3 +132,3 @@ /**

*/
validator(value: unknown, options: any, ctx: FieldContext): any
validator(value: unknown, options: any, field: FieldContext): any

@@ -149,3 +149,3 @@ /**

*/
export type TransformFn<Input, Output> = (value: Input, ctx: FieldContext) => Output
export type TransformFn<Input, Output> = (value: Input, field: FieldContext) => Output

@@ -155,3 +155,3 @@ /**

*/
export type ConditionalFn<Input> = (value: Input, ctx: FieldContext) => boolean
export type ConditionalFn<Input> = (value: Input, field: FieldContext) => boolean

@@ -482,3 +482,3 @@ /**

*/
report(message: string, rule: string, ctx: FieldContext, args?: Record<string, any>): any
report(message: string, rule: string, field: FieldContext, args?: Record<string, any>): any
}

@@ -498,3 +498,3 @@

rule: string,
ctx: FieldContext,
field: FieldContext,
args?: Record<string, any>

@@ -501,0 +501,0 @@ ): string

Sorry, the diff of this file is not supported yet

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