svelte-reflector 2.1.8 → 2.1.9
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.
|
@@ -30,9 +30,18 @@ export type SvelteEvent = {
|
|
|
30
30
|
currentTarget: EventTarget & SeiLa;
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
+
export interface ValidationErrorItem {
|
|
34
|
+
field: string;
|
|
35
|
+
code: string;
|
|
36
|
+
message: string;
|
|
37
|
+
received?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
33
40
|
export interface ApiErrorResponse {
|
|
34
41
|
error: string;
|
|
35
42
|
message: string;
|
|
43
|
+
statusCode?: number;
|
|
44
|
+
errors?: ValidationErrorItem[];
|
|
36
45
|
}
|
|
37
46
|
|
|
38
47
|
export class Behavior<TSuccess = unknown, TError = unknown> {
|
|
@@ -43,6 +52,8 @@ export class Behavior<TSuccess = unknown, TError = unknown> {
|
|
|
43
52
|
export class BuildedInput<T> {
|
|
44
53
|
value = $state<T>(null as any);
|
|
45
54
|
display = $state<T>(null as any);
|
|
55
|
+
private serverErrorMessage = $state<string | null>(null);
|
|
56
|
+
private serverErrorValue = $state.raw<T | null>(null);
|
|
46
57
|
required: boolean;
|
|
47
58
|
nullable: boolean;
|
|
48
59
|
placeholder: T;
|
|
@@ -82,6 +93,21 @@ export class BuildedInput<T> {
|
|
|
82
93
|
if (!this.validator) return null;
|
|
83
94
|
return this.validator(this.value);
|
|
84
95
|
}
|
|
96
|
+
|
|
97
|
+
setServerError(message: string) {
|
|
98
|
+
this.serverErrorMessage = message;
|
|
99
|
+
this.serverErrorValue = this.value;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
clearServerError() {
|
|
103
|
+
this.serverErrorMessage = null;
|
|
104
|
+
this.serverErrorValue = null;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
get serverError(): string | null {
|
|
108
|
+
if (this.serverErrorMessage === null) return null;
|
|
109
|
+
return this.value === this.serverErrorValue ? this.serverErrorMessage : null;
|
|
110
|
+
}
|
|
85
111
|
}
|
|
86
112
|
|
|
87
113
|
export class EnumQueryBuilder<T> {
|