You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP β†’

sveltekit-superforms

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sveltekit-superforms - npm Package Compare versions

Comparing version

to
2.17.0

@@ -5,2 +5,3 @@ import { type AdapterOptions, type ClientValidationAdapter, type ValidationAdapter } from './adapters.js';

export declare const schemasafe: <T extends JSONSchema | Record<string, unknown>, Data = unknown extends FromSchema<T> ? Record<string, unknown> : FromSchema<T>, Out = [Data] extends [never] ? Record<string, unknown> : Data>(schema: T, options?: (AdapterOptions<Out> & {
descriptionAsErrors?: boolean;
config?: ValidatorOptions;

@@ -7,0 +8,0 @@ }) | undefined) => ValidationAdapter<Out>;

import { memoize } from '../memoize.js';
import { createAdapter } from './adapters.js';
import { pathExists } from '../traversal.js';
async function modules() {

@@ -48,3 +49,5 @@ const { validator } = await import(/* webpackIgnore: true */ '@exodus/schemasafe');

issues: (validator.errors ?? []).map(({ instanceLocation, keywordLocation }) => ({
message: keywordLocation,
message: options?.descriptionAsErrors
? errorDescription(schema, keywordLocation)
: keywordLocation,
path: instanceLocation.split('/').slice(1)

@@ -82,1 +85,8 @@ })),

const cache = new WeakMap();
function errorDescription(schema, keywordLocation) {
if (!keywordLocation.startsWith('#/'))
return keywordLocation;
const searchPath = keywordLocation.slice(2).split('/');
const path = pathExists(schema, searchPath);
return path?.parent.description ?? keywordLocation;
}

@@ -9,3 +9,8 @@ import { createAdapter } from './adapters.js';

ignoreUnknownValidation: true,
customSchemaConversion: { custom: () => ({}), instance: () => ({}) }
customSchemaConversion: {
custom: () => ({}),
instance: () => ({}),
file: () => ({}),
blob: () => ({})
}
};

@@ -12,0 +17,0 @@ /* @__NO_SIDE_EFFECTS__ */

@@ -166,2 +166,5 @@ import type { TaintedFields, SuperFormValidated, SuperValidated } from '../superValidate.js';

timeout: Readable<boolean>;
/**
* @deprecated posted is inconsistent between server and client validation, and SPA mode. Will be removed in v3. Use a status message or return your own data in the form action to handle form post status.
*/
posted: Readable<boolean>;

@@ -168,0 +171,0 @@ allErrors: Readable<{

@@ -89,7 +89,7 @@ import { SchemaError } from '../errors.js';

if (info.properties) {
for (const [key, value] of Object.entries(info.properties)) {
assertSchema(value, [...path, key]);
for (const [key, objSchema] of Object.entries(info.properties)) {
assertSchema(objSchema, [...path, key]);
const def = objectDefaults && objectDefaults[key] !== undefined
? objectDefaults[key]
: _defaultValues(value, !info.required?.includes(key), [...path, key]);
: _defaultValues(objSchema, !info.required?.includes(key), [...path, key]);
//if (def !== undefined) output[key] = def;

@@ -103,2 +103,9 @@ output[key] = def;

}
// TODO: [v3] Handle default values for array elements
// if (info.array && info.array.length) {
// console.log('===== Array default =====');
// console.dir(info.array, { depth: 10 }); //debug
// //if (info.array.length > 1) throw new SchemaError('Only one array type is supported.', path);
// console.dir(_defaultValues(info.array[0], info.isOptional, path), { depth: 10 }); //debug
// }
// Enums, return the first value so it can be a required field

@@ -105,0 +112,0 @@ if (schema.enum) {

@@ -41,3 +41,3 @@ import type { AllKeys, IsAny, MergeUnion } from './utils.js';

path: '';
type: Type;
type: Type extends any[] ? Type : Type[];
}>;

@@ -44,0 +44,0 @@ type Concat<Path extends string, Next extends string> = `${Path}${Path extends '' ? '' : '.'}${Next}`;

@@ -15,2 +15,5 @@ import { type ActionFailure, type RequestEvent } from '@sveltejs/kit';

valid: boolean;
/**
* @deprecated posted is inconsistent between server and client validation, and SPA mode. Will be removed in v3. Use a status message or return your own data in the form action to handle form post status.
*/
posted: boolean;

@@ -17,0 +20,0 @@ errors: ValidationErrors<Out>;

@@ -24,3 +24,3 @@ import { traversePath } from './traversal.js';

// Merge with defaults in non-strict mode.
const parsedData = options?.strict ? parsed.data ?? {} : mergeDefaults(parsed.data, defaults);
const parsedData = options?.strict ? (parsed.data ?? {}) : mergeDefaults(parsed.data, defaults);
let status;

@@ -27,0 +27,0 @@ if (!!parsed.data || addErrors) {

{
"name": "sveltekit-superforms",
"version": "2.16.1",
"version": "2.17.0",
"author": "Andreas SΓΆderlund <ciscoheat@gmail.com> (https://blog.encodeart.dev)",

@@ -134,3 +134,3 @@ "description": "Making SvelteKit forms a pleasure to use!",

"@gcornut/valibot-json-schema": "^0.31.0",
"@sinclair/typebox": "^0.32.34",
"@sinclair/typebox": "^0.32.35",
"@sodaru/yup-to-json-schema": "^2.0.1",

@@ -145,3 +145,3 @@ "@vinejs/vine": "^1.8.0",

"zod": "^3.23.8",
"zod-to-json-schema": "^3.23.1"
"zod-to-json-schema": "^3.23.2"
},

@@ -152,11 +152,11 @@ "dependencies": {

"memoize-weak": "^1.0.2",
"ts-deepmerge": "^7.0.0"
"ts-deepmerge": "^7.0.1"
},
"devDependencies": {
"@sveltejs/adapter-auto": "^3.2.2",
"@sveltejs/kit": "^2.5.17",
"@sveltejs/package": "^2.3.2",
"@sveltejs/adapter-auto": "^3.2.3",
"@sveltejs/kit": "^2.5.21",
"@sveltejs/package": "^2.3.3",
"@sveltejs/vite-plugin-svelte": "^3.1.1",
"@types/json-schema": "^7.0.15",
"@types/node": "^20.14.9",
"@types/node": "^20.14.15",
"@types/throttle-debounce": "^5.0.2",

@@ -166,2 +166,3 @@ "@types/uuid": "^9.0.8",

"@typescript-eslint/parser": "^6.21.0",
"@valibot/i18n": "^0.16.0",
"eslint": "^8.57.0",

@@ -171,18 +172,20 @@ "eslint-config-prettier": "^9.1.0",

"eslint-plugin-svelte": "2.36.0-next.13",
"i18next": "^23.12.3",
"only-allow": "^1.2.1",
"prettier": "^3.3.2",
"prettier-plugin-svelte": "^3.2.5",
"publint": "^0.2.8",
"sass": "^1.77.6",
"svelte": "5.0.0-next.180",
"svelte-check": "^3.8.2",
"prettier": "^3.3.3",
"prettier-plugin-svelte": "^3.2.6",
"publint": "^0.2.9",
"sass": "^1.77.8",
"svelte": "5.0.0-next.212",
"svelte-check": "^3.8.5",
"svelte-french-toast": "^1.2.0",
"sveltekit-flash-message": "^2.4.4",
"sveltekit-rate-limiter": "^0.5.1",
"sveltekit-rate-limiter": "^0.5.2",
"throttle-debounce": "^5.0.2",
"tslib": "^2.6.3",
"typescript": "^5.5.2",
"typescript": "^5.5.4",
"uuid": "^9.0.1",
"vite": "^5.3.1",
"vitest": "^1.6.0"
"vite": "^5.4.0",
"vitest": "^1.6.0",
"zod-i18n-map": "^2.27.0"
},

@@ -189,0 +192,0 @@ "svelte": "./dist/index.js",

@@ -23,3 +23,3 @@ <p align="center">

- Server- and client-side validation with your favorite validation libraries, and more to come: πŸ’₯ **Arktype** πŸ’₯ **Joi** πŸ’₯ **TypeBox** πŸ’₯ **Valibot** πŸ’₯ **VineJS** πŸ’₯ **Yup** πŸ’₯ **Zod** πŸ’₯
- Server- and client-side validation with your favorite validation libraries, and more to come: πŸ’₯ **Arktype** πŸ’₯ **Joi** πŸ’₯ **Superstruct** πŸ’₯ **TypeBox** πŸ’₯ **Valibot** πŸ’₯ **VineJS** πŸ’₯ **Yup** πŸ’₯ **Zod** πŸ’₯ or use **JSON Schema** directly.
- Seamless merging of `PageData` and `ActionData` - Forget about which one to use and how, just focus on your form data.

@@ -26,0 +26,0 @@ - [Auto-centering and focusing](https://superforms.rocks/concepts/error-handling#usage-client) on invalid form fields.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display