vue3-form-validation
Advanced tools
Comparing version 3.0.6 to 3.1.0
import { Ref, ComputedRef, UnwrapRef } from 'vue'; | ||
import { RefUnref } from '../utils'; | ||
import { RefUnref } from '../types'; | ||
export declare type SimpleRule<T = any> = (value: T) => any; | ||
export declare type KeyedRule<T = any> = { | ||
key: string; | ||
rule: SimpleRule<T>; | ||
rule?: SimpleRule<T>; | ||
}; | ||
@@ -11,3 +11,3 @@ export declare type Rule<T = any> = SimpleRule<T> | KeyedRule<T>; | ||
$value: RefUnref<TValue>; | ||
$rules?: Rule<UnwrapRef<TValue>>[]; | ||
$rules?: Rule<TValue extends any[] ? TValue : UnwrapRef<TValue>>[]; | ||
}; | ||
@@ -14,0 +14,0 @@ export declare type TransformedField<T> = { |
import { reactive } from 'vue'; | ||
import { Form } from '../common/Form'; | ||
import { ValidationError } from '../common/ValidationError'; | ||
import { cleanupForm, getResultFormData, path, PromiseCancel, resetFields, transformFormData } from '../utils'; | ||
import { path, PromiseCancel } from '../common'; | ||
import { Form } from '../form/Form'; | ||
import { ValidationError } from '../form/ValidationError'; | ||
import { cleanupForm, getResultFormData, resetFields, transformFormData } from './helper'; | ||
/** | ||
@@ -36,4 +37,3 @@ * | ||
form.submitting.value = true; | ||
const resultFormData = {}; | ||
getResultFormData(transformedFormData, resultFormData); | ||
const resultFormData = getResultFormData(transformedFormData); | ||
const hasError = await promiseCancel.race(form.validateAll()); | ||
@@ -40,0 +40,0 @@ form.submitting.value = false; |
export { useValidation } from './composition/useValidation'; | ||
export { ValidationError } from './common/ValidationError'; | ||
export type { Field, Rule, KeyedRule, SimpleRule } from './composition/useValidation'; | ||
export { ValidationError } from './form/ValidationError'; | ||
export type { Field } from './composition/useValidation'; |
export { useValidation } from './composition/useValidation'; | ||
export { ValidationError } from './common/ValidationError'; | ||
export { ValidationError } from './form/ValidationError'; |
{ | ||
"name": "vue3-form-validation", | ||
"version": "3.0.6", | ||
"version": "3.1.0", | ||
"description": "Vue composition function for Form Validation", | ||
@@ -30,3 +30,2 @@ "author": { | ||
"build": "npx eslint --rule=\"no-console:error\" --max-warnings 0 --fix-dry-run main && npx tsc --project ./main", | ||
"lint": "npx prettier --write .", | ||
"test": "jest --config ./main/jest.config.ts", | ||
@@ -41,24 +40,26 @@ "test-dts": "npx tsd", | ||
"devDependencies": { | ||
"@types/jest": "^26.0.21", | ||
"@types/node": "^14.14.35", | ||
"@typescript-eslint/eslint-plugin": "^4.18.0", | ||
"@typescript-eslint/parser": "^4.18.0", | ||
"@vitejs/plugin-vue": "^1.1.5", | ||
"@vue/compiler-sfc": "^3.0.7", | ||
"@heroicons/vue": "^1.0.1", | ||
"@types/jest": "^26.0.23", | ||
"@types/node": "^15.3.0", | ||
"@typescript-eslint/eslint-plugin": "^4.23.0", | ||
"@typescript-eslint/parser": "^4.23.0", | ||
"@vitejs/plugin-vue": "^1.2.2", | ||
"@vue/compiler-sfc": "^3.0.11", | ||
"autoprefixer": "^10.2.5", | ||
"eslint": "^7.22.0", | ||
"eslint-config-prettier": "^8.1.0", | ||
"eslint-plugin-vue": "^7.7.0", | ||
"husky": "^5.1.3", | ||
"eslint": "^7.26.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-vue": "^7.9.0", | ||
"husky": "^6.0.0", | ||
"jest": "^26.6.3", | ||
"lint-staged": "^10.5.4", | ||
"lint-staged": "^11.0.0", | ||
"pinst": "^2.1.6", | ||
"postcss": "^8.2.8", | ||
"prettier": "^2.2.1", | ||
"tailwindcss": "^2.0.4", | ||
"ts-jest": "^26.5.4", | ||
"postcss": "^8.2.15", | ||
"postcss-nesting": "^8.0.1", | ||
"prettier": "^2.3.0", | ||
"tailwindcss": "^2.1.2", | ||
"ts-jest": "^26.5.6", | ||
"ts-node": "^9.1.1", | ||
"tsd": "^0.14.0", | ||
"typescript": "^4.2.3", | ||
"vite": "^2.1.2", | ||
"tsd": "^0.15.1", | ||
"typescript": "^4.2.4", | ||
"vite": "^2.3.2", | ||
"vue": "^3.0.7", | ||
@@ -74,4 +75,11 @@ "vue-router": "^4.0.4" | ||
"tsd": { | ||
"directory": "test-dts" | ||
"directory": "main/test-dts", | ||
"compilerOptions": { | ||
"lib": [ | ||
"DOM", | ||
"ES2020" | ||
], | ||
"strict": true | ||
} | ||
} | ||
} |
@@ -15,4 +15,6 @@ # 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-7mp4z?file=/src/views/SignupForm.vue). | ||
Validation is async and is utilising `Promise.allSettled`. | ||
### :point_right: [Check out the example usage on Code Sandbox](https://codesandbox.io/s/vue-3-form-validation-demo-7mp4z?file=/src/views/SignupForm.vue) | ||
## API | ||
@@ -118,3 +120,3 @@ | ||
Given the structure of the previous example, this will result in the following type: | ||
Given the structure of the previous example, this will result in the following object: | ||
@@ -179,3 +181,3 @@ ```ts | ||
```ts | ||
type SimpleRule<T = any> = (value: T) => Promise<unknown> | unknown; | ||
type SimpleRule<T = any> = (value: T) => any; | ||
type KeyedRule<T = any> = { key: string; rule: SimpleRule<T> }; | ||
@@ -182,0 +184,0 @@ type Rule<T = any> = SimpleRule<T> | KeyedRule<T>; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
40576
39
836
228
26