Skip to content

Commit 8e34539

Browse files
committed
docs: update documentation
1 parent 2ac6cc2 commit 8e34539

File tree

26 files changed

+8286
-89
lines changed

26 files changed

+8286
-89
lines changed

website/docs/usage_with_frameworks/react.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ function SignupForm() {
3737

3838
const handleChange = (name, value) => {
3939
setFormData(prev => ({ ...prev, [name]: value }));
40-
suite.afterEach(setResult).run({ ...formData, [name]: value }, name);
40+
suite
41+
.afterEach(() => setResult(suite.get()))
42+
.run({ ...formData, [name]: value }, name);
4143
};
4244

4345
return (
@@ -89,8 +91,8 @@ function useVestForm(suite, initialData = {}) {
8991
setFormData(newData);
9092

9193
suite
92-
.afterEach(res => {
93-
setResult(res);
94+
.afterEach(() => {
95+
setResult(suite.get());
9496
})
9597
.run(newData, fieldName);
9698
},
@@ -99,8 +101,8 @@ function useVestForm(suite, initialData = {}) {
99101

100102
const validateAll = useCallback(() => {
101103
suite
102-
.afterEach(res => {
103-
setResult(res);
104+
.afterEach(() => {
105+
setResult(suite.get());
104106
})
105107
.run(formData);
106108
}, [formData, suite]);
@@ -216,8 +218,8 @@ function UsernameField() {
216218
setIsChecking(true);
217219

218220
suite
219-
.afterEach(res => {
220-
setResult(res);
221+
.afterEach(() => {
222+
setResult(suite.get());
221223
setIsChecking(false);
222224
})
223225
.run({ username: value }, 'username');
@@ -272,7 +274,7 @@ const handleFieldChange = (fieldName, value) => {
272274

273275
// Only validate the changed field
274276
suite
275-
.afterEach(setResult)
277+
.afterEach(() => setResult(suite.get()))
276278
.run({ ...formData, [fieldName]: value }, fieldName);
277279
};
278280
```
@@ -287,7 +289,8 @@ const handleSubmit = e => {
287289

288290
// Validate all fields
289291
suite
290-
.afterEach(result => {
292+
.afterEach(() => {
293+
const result = suite.get();
291294
if (!result.hasErrors()) {
292295
// Submit form
293296
submitForm(formData);

website/docs/usage_with_frameworks/svelte.md

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,14 @@ Vest integrates naturally with Svelte's reactive stores and reactive statements,
4040
let result = suite.get();
4141
4242
function validateField(fieldName) {
43-
suite.afterEach((res) => {
44-
result = res;
43+
suite.afterEach(() => {
44+
result = suite.get();
4545
}).run(formData, fieldName);
4646
}
4747
4848
function handleSubmit() {
49-
suite.afterEach((res) => {
49+
suite.afterEach(() => {
50+
const res = suite.get();
5051
result = res;
5152
5253
if (!res.hasErrors()) {
@@ -127,13 +128,14 @@ Create a reactive store for your validation results:
127128
function validateField(fieldName, value) {
128129
formData.update(data => ({ ...data, [fieldName]: value }));
129130
130-
suite.afterEach((res) => {
131-
validationResult.set(res);
131+
suite.afterEach(() => {
132+
validationResult.set(suite.get());
132133
}).run($formData, fieldName);
133134
}
134135
135136
function handleSubmit() {
136-
suite.afterEach((res) => {
137+
suite.afterEach(() => {
138+
const res = suite.get();
137139
validationResult.set(res);
138140
139141
if (!res.hasErrors()) {
@@ -177,8 +179,8 @@ Use Svelte's reactive statements for automatic validation:
177179
178180
// Automatically validate when username changes
179181
$: if (username !== undefined) {
180-
suite.afterEach((res) => {
181-
result = res;
182+
suite.afterEach(() => {
183+
result = suite.get();
182184
}).run({ username }, 'username');
183185
}
184186
</script>
@@ -219,8 +221,8 @@ Handle async validations with Svelte's reactivity:
219221
async function checkUsername() {
220222
isChecking = true;
221223
222-
suite.afterEach((res) => {
223-
result = res;
224+
suite.afterEach(() => {
225+
result = suite.get();
224226
isChecking = false;
225227
}).run({ username }, 'username');
226228
}
@@ -322,8 +324,8 @@ export function createValidationStore(suite, initialData = {}) {
322324

323325
const currentData = get(formData);
324326
suite
325-
.afterEach(res => {
326-
result.set(res);
327+
.afterEach(() => {
328+
result.set(suite.get());
327329
isValidating.set(false);
328330
})
329331
.run(currentData, fieldName);
@@ -334,8 +336,8 @@ export function createValidationStore(suite, initialData = {}) {
334336

335337
const currentData = get(formData);
336338
suite
337-
.afterEach(res => {
338-
result.set(res);
339+
.afterEach(() => {
340+
result.set(suite.get());
339341
isValidating.set(false);
340342
})
341343
.run(currentData);
@@ -445,8 +447,8 @@ Vest works great with [TypeScript](/docs/typescript_support) in Svelte:
445447
let result: SuiteResult = suite.get();
446448
447449
function validateField(fieldName: keyof FormData): void {
448-
suite.afterEach((res) => {
449-
result = res;
450+
suite.afterEach(() => {
451+
result = suite.get();
450452
}).run(formData, fieldName);
451453
}
452454
</script>
@@ -478,7 +480,7 @@ Use debouncing for async or expensive validations:
478480
import { debounce } from './utils';
479481
480482
const validateUsername = debounce((value) => {
481-
suite.afterEach(setResult).run({ username: value }, 'username');
483+
suite.afterEach(() => setResult(suite.get())).run({ username: value }, 'username');
482484
}, 500);
483485
484486
$: validateUsername(username);

website/docs/usage_with_frameworks/vanilla.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ Vest works perfectly with plain JavaScript without any framework dependencies. T
7272
7373
function validateField(fieldName) {
7474
const result = suite
75-
.afterEach(res => {
76-
updateErrorDisplay(fieldName, res);
75+
.afterEach(() => {
76+
updateErrorDisplay(fieldName, suite.get());
7777
})
7878
.run(formData, fieldName);
7979
}
@@ -104,7 +104,8 @@ Vest works perfectly with plain JavaScript without any framework dependencies. T
104104
e.preventDefault();
105105
106106
suite
107-
.afterEach(res => {
107+
.afterEach(() => {
108+
const res = suite.get();
108109
if (!res.hasErrors()) {
109110
console.log('Form is valid!', formData);
110111
// Submit form
@@ -220,16 +221,17 @@ class FormValidator {
220221

221222
validateField(fieldName) {
222223
this.suite
223-
.afterEach(result => {
224-
this.updateFieldUI(fieldName, result);
224+
.afterEach(() => {
225+
this.updateFieldUI(fieldName, this.suite.get());
225226
})
226227
.run(this.formData, fieldName);
227228
}
228229

229230
validateAll() {
230231
return new Promise(resolve => {
231232
this.suite
232-
.afterEach(result => {
233+
.afterEach(() => {
234+
const result = this.suite.get();
233235
// Update UI for all fields
234236
Object.keys(this.formData).forEach(fieldName => {
235237
this.touched[fieldName] = true;
@@ -368,7 +370,8 @@ usernameInput.addEventListener('input', e => {
368370

369371
debounceTimer = setTimeout(() => {
370372
suite
371-
.afterEach(result => {
373+
.afterEach(() => {
374+
const result = suite.get();
372375
loadingIndicator.style.display = 'none';
373376
updateErrorDisplay('username', result);
374377
})

website/docs/usage_with_frameworks/vue.md

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,16 @@ const result = ref(suite.get());
4141
4242
const validateField = fieldName => {
4343
suite
44-
.afterEach(res => {
45-
result.value = res;
44+
.afterEach(() => {
45+
result.value = suite.get();
4646
})
4747
.run(formData, fieldName);
4848
};
4949
5050
const handleSubmit = () => {
5151
suite
52-
.afterEach(res => {
52+
.afterEach(() => {
53+
const res = suite.get();
5354
result.value = res;
5455
5556
if (!res.hasErrors()) {
@@ -108,8 +109,8 @@ export function useVestForm(suite, initialData = {}) {
108109
isValidating.value = true;
109110

110111
suite
111-
.afterEach(res => {
112-
result.value = res;
112+
.afterEach(() => {
113+
result.value = suite.get();
113114
isValidating.value = false;
114115
})
115116
.run(formData, fieldName);
@@ -119,8 +120,8 @@ export function useVestForm(suite, initialData = {}) {
119120
isValidating.value = true;
120121

121122
suite
122-
.afterEach(res => {
123-
result.value = res;
123+
.afterEach(() => {
124+
result.value = suite.get();
124125
isValidating.value = false;
125126
})
126127
.run(formData);
@@ -219,8 +220,8 @@ const checkUsername = () => {
219220
isChecking.value = true;
220221
221222
suite
222-
.afterEach(res => {
223-
result.value = res;
223+
.afterEach(() => {
224+
result.value = suite.get();
224225
isChecking.value = false;
225226
})
226227
.run(formData, 'username');
@@ -275,14 +276,15 @@ export default {
275276
methods: {
276277
validateField(fieldName) {
277278
suite
278-
.afterEach(res => {
279-
this.result = res;
279+
.afterEach(() => {
280+
this.result = suite.get();
280281
})
281282
.run(this.formData, fieldName);
282283
},
283284
handleSubmit() {
284285
suite
285-
.afterEach(res => {
286+
.afterEach(() => {
287+
const res = suite.get();
286288
this.result = res;
287289
288290
if (!res.hasErrors()) {
@@ -392,8 +394,8 @@ const result = ref<SuiteResult>(suite.get());
392394
393395
const validateField = (fieldName: keyof FormData) => {
394396
suite
395-
.afterEach(res => {
396-
result.value = res;
397+
.afterEach(() => {
398+
result.value = suite.get();
397399
})
398400
.run(formData, fieldName);
399401
};
@@ -440,7 +442,9 @@ watchDebounced(
440442
username,
441443
newValue => {
442444
// Validate username
443-
suite.afterEach(setResult).run({ username: newValue }, 'username');
445+
suite
446+
.afterEach(() => setResult(suite.get()))
447+
.run({ username: newValue }, 'username');
444448
},
445449
{ debounce: 500 },
446450
);

website/docusaurus.config.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,6 @@ const config = {
3030
},
3131
},
3232
organizationName: 'ealush', // Usually your GitHub org/user name.
33-
plugins: [
34-
[
35-
'@docusaurus/plugin-google-gtag',
36-
{
37-
trackingID: 'G-M420W03G2K',
38-
anonymizeIP: true,
39-
},
40-
],
41-
],
4233
presets: [
4334
[
4435
'@docusaurus/preset-classic',
@@ -80,6 +71,10 @@ const config = {
8071
theme: {
8172
customCss: path.resolve(__dirname, './src/css/custom.css'),
8273
},
74+
gtag: {
75+
trackingID: 'G-M420W03G2K',
76+
anonymizeIP: true,
77+
},
8378
}),
8479
],
8580
],

website/sidebars.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const sidebars = {
2222
items: [
2323
'usage_with_frameworks/react',
2424
'usage_with_frameworks/vue',
25-
'usage_with_frameworks/svelte',
25+
2626
'usage_with_frameworks/vanilla',
2727
],
2828
},

website/src/components/HomepageFeatures.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ const FeatureList = [
4646
description:
4747
'Vest remembers previous runs and merges results, allowing you to validate only the fields the user is interacting with.',
4848
},
49+
{
50+
title: 'Full stack',
51+
emoji: '🥞',
52+
category: 'Universal',
53+
description:
54+
'Run the same validation logic on both client and server. Share your suite between environments for consistent, tamper-proof validation.',
55+
},
4956
];
5057

5158
function Feature({ emoji, title, category, description }) {

website/src/components/RawExample.module.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
.codeWindow {
2121
margin-left: 4rem;
22+
margin-bottom: 2rem;
2223
border-radius: 12px;
2324
box-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.25);
2425
overflow: hidden;

0 commit comments

Comments
 (0)