@streamscloud/kit 0.1.7-1771253652477 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type-level test file for YupFormValidator compatibility with yup.object<T>().
|
|
3
|
-
* This file reproduces usage patterns from the frontend app.
|
|
4
|
-
* If svelte-check/tsc passes on this file — Yup upgrade is safe.
|
|
5
|
-
*
|
|
6
|
-
* NOT a runtime test — purely compile-time type checking.
|
|
7
|
-
*/
|
|
8
|
-
import { FormValidationHandler } from '../form-validation-handler/form-validation-handler.svelte';
|
|
9
|
-
import { YupFormValidator } from '../form-validation-handler/yup-form-validator';
|
|
10
|
-
import { emailValidationSchema } from '../validation-schemas/email-validation';
|
|
11
|
-
import { handleValidationSchema } from '../validation-schemas/handle-validations';
|
|
12
|
-
import { numberValidationSchema } from '../validation-schemas/number-validations';
|
|
13
|
-
import { textValidationSchema } from '../validation-schemas/text-validations';
|
|
14
|
-
import * as yup from 'yup';
|
|
15
|
-
const _loginValidator = new YupFormValidator(yup.object({
|
|
16
|
-
username: emailValidationSchema(),
|
|
17
|
-
password: yup.string().required()
|
|
18
|
-
}));
|
|
19
|
-
const _loginHandler = new FormValidationHandler({
|
|
20
|
-
initialValues: { username: '', password: '' },
|
|
21
|
-
validator: _loginValidator
|
|
22
|
-
});
|
|
23
|
-
const _textFieldValidator = new YupFormValidator(yup.object({
|
|
24
|
-
value: yup.string().required().nullable()
|
|
25
|
-
}));
|
|
26
|
-
const _numberFieldValidator = new YupFormValidator(yup.object({
|
|
27
|
-
value: yup.number().required().nullable()
|
|
28
|
-
}));
|
|
29
|
-
const _surveyValidator = new YupFormValidator(yup.object({
|
|
30
|
-
name: yup.string().required().max(30)
|
|
31
|
-
}));
|
|
32
|
-
const _profileValidator = new YupFormValidator(yup.object({
|
|
33
|
-
id: yup.string().required(),
|
|
34
|
-
username: handleValidationSchema(),
|
|
35
|
-
name: textValidationSchema({ maxLength: 100, minLength: 3 }),
|
|
36
|
-
image: yup.object().nullable(),
|
|
37
|
-
position: yup.string().nullable()
|
|
38
|
-
}));
|
|
39
|
-
const _streamInfoValidator = new YupFormValidator(yup.object({
|
|
40
|
-
name: textValidationSchema({ maxLength: 100, minLength: 1 }),
|
|
41
|
-
slug: handleValidationSchema(),
|
|
42
|
-
description: textValidationSchema({ maxLength: 500, minLength: 0 })
|
|
43
|
-
}));
|
|
44
|
-
const _pricingValidator = new YupFormValidator(yup.object({
|
|
45
|
-
price: numberValidationSchema({ isRequired: true, minValue: 0, maxValue: null, minExclusive: false, maxExclusive: false }),
|
|
46
|
-
quantity: yup.number().nullable()
|
|
47
|
-
}));
|
|
48
|
-
// ============================================================
|
|
49
|
-
// Pattern 7: Schema without explicit generic (plain inference)
|
|
50
|
-
// ============================================================
|
|
51
|
-
const _plainValidator = new YupFormValidator(yup.object({
|
|
52
|
-
email: emailValidationSchema()
|
|
53
|
-
}));
|
|
54
|
-
const _inlineHandler = new FormValidationHandler({
|
|
55
|
-
initialValues: { title: '', count: 0 },
|
|
56
|
-
validator: new YupFormValidator(yup.object({
|
|
57
|
-
title: yup.string().required(),
|
|
58
|
-
count: yup.number().required()
|
|
59
|
-
}))
|
|
60
|
-
});
|
|
61
|
-
// ============================================================
|
|
62
|
-
// Pattern 9: Verify that IFormHandlerValidator<T> still enforces
|
|
63
|
-
// correct error field types (the "reverse validation" concern)
|
|
64
|
-
// ============================================================
|
|
65
|
-
const _verifyErrorTypes = async () => {
|
|
66
|
-
const handler = new FormValidationHandler({
|
|
67
|
-
initialValues: { username: '', password: '' },
|
|
68
|
-
validator: _loginValidator
|
|
69
|
-
});
|
|
70
|
-
// errors is typed as { [P in keyof Partial<LoginModel>]: string }
|
|
71
|
-
// i.e. { username?: string; password?: string }
|
|
72
|
-
const _usernameError = handler.errors.username;
|
|
73
|
-
const _passwordError = handler.errors.password;
|
|
74
|
-
// @ts-expect-error — 'nonExistentField' does not exist on LoginModel
|
|
75
|
-
const _badField = handler.errors.nonExistentField;
|
|
76
|
-
void _usernameError;
|
|
77
|
-
void _passwordError;
|
|
78
|
-
void _badField;
|
|
79
|
-
};
|
|
80
|
-
// Schema validates 'baz' which doesn't exist on ModelA — correctly fails!
|
|
81
|
-
// With ObjectSchema<Partial<T>, any, any, any> this mismatch is now caught.
|
|
82
|
-
// @ts-expect-error — schema fields don't match ModelA
|
|
83
|
-
const _mismatchedValidator = new YupFormValidator(yup.object({ baz: yup.string().required() }));
|
|
84
|
-
// Prevent unused variable warnings
|
|
85
|
-
void _loginValidator;
|
|
86
|
-
void _loginHandler;
|
|
87
|
-
void _textFieldValidator;
|
|
88
|
-
void _numberFieldValidator;
|
|
89
|
-
void _surveyValidator;
|
|
90
|
-
void _profileValidator;
|
|
91
|
-
void _streamInfoValidator;
|
|
92
|
-
void _pricingValidator;
|
|
93
|
-
void _plainValidator;
|
|
94
|
-
void _inlineHandler;
|
|
95
|
-
void _verifyErrorTypes;
|
|
96
|
-
void _mismatchedValidator;
|