@tanstack/form-core
Advanced tools
Comparing version 0.8.0 to 0.8.1
@@ -32,6 +32,3 @@ // src/FormApi.ts | ||
const doValidate = () => { | ||
if (typeof this.options.onMount === "function") { | ||
return this.options.onMount(this.state.values, this); | ||
} | ||
if (this.options.validator) { | ||
if (this.options.validator && typeof this.options.onMount !== "function") { | ||
return this.options.validator().validate( | ||
@@ -42,3 +39,9 @@ this.state.values, | ||
} | ||
return this.options.onMount( | ||
this.state.values, | ||
this | ||
); | ||
}; | ||
if (!this.options.onMount) | ||
return; | ||
const error = doValidate(); | ||
@@ -107,5 +110,2 @@ if (error) { | ||
const doValidate = () => { | ||
if (typeof validate === "function") { | ||
return validate(this.state.values, this); | ||
} | ||
if (this.options.validator && typeof validate !== "function") { | ||
@@ -117,4 +117,5 @@ return this.options.validator().validate( | ||
} | ||
throw new Error( | ||
`Form validation for ${errorMapKey} failed. ${errorMapKey} should either be a function, or \`validator\` should be correct.` | ||
return validate( | ||
this.state.values, | ||
this | ||
); | ||
@@ -121,0 +122,0 @@ }; |
@@ -32,6 +32,3 @@ // src/FormApi.ts | ||
const doValidate = () => { | ||
if (typeof this.options.onMount === "function") { | ||
return this.options.onMount(this.state.values, this); | ||
} | ||
if (this.options.validator) { | ||
if (this.options.validator && typeof this.options.onMount !== "function") { | ||
return this.options.validator().validate( | ||
@@ -42,3 +39,9 @@ this.state.values, | ||
} | ||
return this.options.onMount( | ||
this.state.values, | ||
this | ||
); | ||
}; | ||
if (!this.options.onMount) | ||
return; | ||
const error = doValidate(); | ||
@@ -104,5 +107,2 @@ if (error) { | ||
const doValidate = () => { | ||
if (typeof validate === "function") { | ||
return validate(this.state.values, this); | ||
} | ||
if (this.options.validator && typeof validate !== "function") { | ||
@@ -114,4 +114,5 @@ return this.options.validator().validate( | ||
} | ||
throw new Error( | ||
`Form validation for ${errorMapKey} failed. ${errorMapKey} should either be a function, or \`validator\` should be correct.` | ||
return validate( | ||
this.state.values, | ||
this | ||
); | ||
@@ -118,0 +119,0 @@ }; |
{ | ||
"name": "@tanstack/form-core", | ||
"version": "0.8.0", | ||
"version": "0.8.1", | ||
"description": "Powerful, type-safe, framework agnostic forms.", | ||
@@ -5,0 +5,0 @@ "author": "tannerlinsley", |
@@ -180,6 +180,6 @@ import { Store } from '@tanstack/store' | ||
const doValidate = () => { | ||
if (typeof this.options.onMount === 'function') { | ||
return this.options.onMount(this.state.values, this) | ||
} | ||
if (this.options.validator) { | ||
if ( | ||
this.options.validator && | ||
typeof this.options.onMount !== 'function' | ||
) { | ||
return (this.options.validator as Validator<TFormData>)().validate( | ||
@@ -190,3 +190,8 @@ this.state.values, | ||
} | ||
return (this.options.onMount as ValidateFn<TFormData, ValidatorType>)( | ||
this.state.values, | ||
this, | ||
) | ||
} | ||
if (!this.options.onMount) return | ||
const error = doValidate() | ||
@@ -274,5 +279,2 @@ if (error) { | ||
const doValidate = () => { | ||
if (typeof validate === 'function') { | ||
return validate(this.state.values, this) as ValidationError | ||
} | ||
if (this.options.validator && typeof validate !== 'function') { | ||
@@ -284,4 +286,6 @@ return (this.options.validator as Validator<TFormData>)().validate( | ||
} | ||
throw new Error( | ||
`Form validation for ${errorMapKey} failed. ${errorMapKey} should either be a function, or \`validator\` should be correct.`, | ||
return (validate as ValidateFn<TFormData, ValidatorType>)( | ||
this.state.values, | ||
this, | ||
) | ||
@@ -288,0 +292,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
6142
471981