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

vue3-form-validation

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue3-form-validation - npm Package Compare versions

Comparing version 3.0.1 to 3.0.2

25

dist/composable/useValidation.d.ts

@@ -10,3 +10,3 @@ import { Ref, ComputedRef, UnwrapRef } from 'vue';

export declare type Field<TValue> = {
$value: TValue extends Ref ? TValue | UnwrapRef<TValue> : TValue extends Record<string, unknown> | any[] ? RefUnref<TValue> : Ref<TValue> | TValue;
$value: TValue extends Ref ? TValue | UnwrapRef<TValue> : TValue extends any[] ? TValue : TValue extends Record<string, unknown> ? RefUnref<TValue> : Ref<TValue> | TValue;
$rules?: Rule<UnwrapRef<TValue>>[];

@@ -21,14 +21,9 @@ };

};
export declare type RefUnref<T extends Record<string, unknown> | any[]> = {
[K in keyof T]: T[K] extends Ref ? T[K] | UnwrapRef<T[K]> : T[K] extends Array<infer TArray> ? RefUnref<TArray[]> : T[K] extends Record<string, unknown> ? RefUnref<T[K]> : Ref<T[K]> | T[K];
export declare type RefUnref<T extends Record<string, unknown>> = {
[K in keyof T]: T[K] extends Ref ? T[K] | UnwrapRef<T[K]> : T[K] extends any[] ? T[K] : T[K] extends Record<string, unknown> ? RefUnref<T[K]> : Ref<T[K]> | T[K];
};
export declare type ValidateInput<T extends object | any[]> = {
[K in keyof T]: T[K] extends {
$value: infer TValue;
} ? Field<TValue> : T[K] extends Array<infer TArray> ? ValidateInput<TArray[]> : T[K] extends Record<string, unknown> ? ValidateInput<T[K]> : unknown;
};
export declare type TransformedFormData<T extends object> = T extends any ? {
[K in keyof T]: T[K] extends {
$value: infer TValue;
} ? TransformedField<UnwrapRef<TValue>> : T[K] extends Array<infer TArray> ? TransformedFormData<TArray[]> : T[K] extends Record<string, unknown> ? TransformedFormData<T[K]> : T[K];
} ? TransformedField<UnwrapRef<TValue>> : T[K] extends Record<string, unknown> | any[] ? TransformedFormData<T[K]> : T[K];
} : never;

@@ -38,3 +33,3 @@ export declare type FormData<T extends object> = T extends any ? {

$value: infer TValue;
} ? UnwrapRef<TValue> : T[K] extends Array<infer TArray> ? FormData<TArray[]> : T[K] extends Record<string, unknown> ? FormData<T[K]> : T[K];
} ? UnwrapRef<TValue> : T[K] extends Record<string, unknown> | any[] ? FormData<T[K]> : T[K];
} : never;

@@ -55,4 +50,4 @@ export declare type Keys = readonly (string | number)[];

resetFields(): void;
add<Ks extends Keys>(pathToArray: readonly [...Ks], value: DeepIndex<ValidateInput<T>, Ks> extends Array<infer TArray> ? TArray : never): void;
remove<Ks extends Keys>(pathToArray: readonly [...Ks], index: DeepIndex<ValidateInput<T>, Ks> extends any[] ? number : never): void;
add<Ks extends Keys>(pathToArray: readonly [...Ks], value: DeepIndex<T, Ks> extends Array<infer TArray> ? TArray : never): void;
remove<Ks extends Keys>(pathToArray: readonly [...Ks], index: DeepIndex<T, Ks> extends any[] ? number : never): void;
};

@@ -67,4 +62,4 @@ /**

* @typescript
* For best type inference, consider defining the structure
* of your `formData` upfront and pass it as the generic parameter `T`. For example:
* For better type inference, consider defining the structure
* of your `formData` upfront and pass it as the generic parameter `T`:
* ```

@@ -80,3 +75,3 @@ * type FormData = {

*/
export declare function useValidation<T extends object>(formData: T & ValidateInput<T>): UseValidation<T>;
export declare function useValidation<T extends object>(formData: T): UseValidation<T>;
export {};

8

dist/composable/useValidation.js

@@ -30,5 +30,5 @@ import { reactive, watch, ref } from 'vue';

});
watch(formField.modelValue, () => {
watch(formField.modelValue, async () => {
if (formField.touched) {
form.validate(uid);
await form.validate(uid);
}

@@ -81,4 +81,4 @@ });

* @typescript
* For best type inference, consider defining the structure
* of your `formData` upfront and pass it as the generic parameter `T`. For example:
* For better type inference, consider defining the structure
* of your `formData` upfront and pass it as the generic parameter `T`:
* ```

@@ -85,0 +85,0 @@ * type FormData = {

@@ -14,3 +14,5 @@ import { computed, isRef, reactive, ref } from 'vue';

}
else if (typeof modelValue === 'object' && modelValue !== null) {
else if (typeof modelValue === 'object' &&
!Array.isArray(modelValue) &&
modelValue !== null) {
this.modelValue = reactive(modelValue);

@@ -17,0 +19,0 @@ this.initialModelValue = JSON.parse(JSON.stringify(this.modelValue));

{
"name": "vue3-form-validation",
"version": "3.0.1",
"version": "3.0.2",
"description": "Vue composition function for Form Validation",

@@ -29,3 +29,3 @@ "author": {

"scripts": {
"build": "npx eslint --rule=\"no-console:error\" --fix-dry-run main && npx tsc --project ./main",
"build": "npx eslint --rule=\"no-console:error\" --max-warnings 0 --fix-dry-run main && npx tsc --project ./main",
"lint": "npx prettier --write .",

@@ -32,0 +32,0 @@ "test": "jest --config ./main/jest.config.ts",

@@ -15,3 +15,3 @@ # Form Validation for Vue 3

Validation is async and is utilising `Promise.allSettled`, [which](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled) has not yet reached cross-browser stability. Example usage can be found in this [Code Sandbox](https://codesandbox.io/s/vue-3-form-validation-demo-busd9?file=/src/LoginForm.vue).
Validation is async and is utilising `Promise.allSettled`, [which](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled) has not yet reached cross-browser stability. Example usage can be found in this [Code Sandbox](https://codesandbox.io/s/vue-3-form-validation-demo-busd9?file=/src/views/LoginForm.vue).

@@ -18,0 +18,0 @@ ## API

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