@evolu/common 8.2.0 → 8.3.1

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.
Files changed (221) hide show
  1. package/dist/src/Function.d.ts +1 -0
  2. package/dist/src/Function.d.ts.map +1 -1
  3. package/dist/src/Http.d.ts +9 -0
  4. package/dist/src/Http.d.ts.map +1 -1
  5. package/dist/src/Object.d.ts +1 -0
  6. package/dist/src/Object.d.ts.map +1 -1
  7. package/dist/src/RefCount.d.ts +1 -0
  8. package/dist/src/RefCount.d.ts.map +1 -1
  9. package/dist/src/Relation.d.ts +2 -0
  10. package/dist/src/Relation.d.ts.map +1 -1
  11. package/dist/src/Resource.d.ts +1 -0
  12. package/dist/src/Resource.d.ts.map +1 -1
  13. package/dist/src/Result.d.ts +383 -548
  14. package/dist/src/Result.d.ts.map +1 -1
  15. package/dist/src/Result.js +296 -46
  16. package/dist/src/StackTrace.d.ts +1 -0
  17. package/dist/src/StackTrace.d.ts.map +1 -1
  18. package/dist/src/Task.d.ts +985 -1069
  19. package/dist/src/Task.d.ts.map +1 -1
  20. package/dist/src/Task.js +1007 -156
  21. package/dist/src/Time.d.ts +1 -0
  22. package/dist/src/Time.d.ts.map +1 -1
  23. package/dist/src/Type.d.ts +1322 -793
  24. package/dist/src/Type.d.ts.map +1 -1
  25. package/dist/src/Type.js +1192 -244
  26. package/dist/src/intl/_en.d.ts +126 -0
  27. package/dist/src/intl/_en.d.ts.map +1 -0
  28. package/dist/src/intl/_en.js +267 -0
  29. package/dist/src/intl/ar.d.ts +117 -0
  30. package/dist/src/intl/ar.d.ts.map +1 -0
  31. package/dist/src/intl/ar.js +245 -0
  32. package/dist/src/intl/bn.d.ts +117 -0
  33. package/dist/src/intl/bn.d.ts.map +1 -0
  34. package/dist/src/intl/bn.js +258 -0
  35. package/dist/src/intl/ca.d.ts +117 -0
  36. package/dist/src/intl/ca.d.ts.map +1 -0
  37. package/dist/src/intl/ca.js +258 -0
  38. package/dist/src/intl/cs.d.ts +20 -7
  39. package/dist/src/intl/cs.d.ts.map +1 -1
  40. package/dist/src/intl/cs.js +54 -27
  41. package/dist/src/intl/da.d.ts +117 -0
  42. package/dist/src/intl/da.d.ts.map +1 -0
  43. package/dist/src/intl/da.js +258 -0
  44. package/dist/src/intl/de.d.ts +117 -0
  45. package/dist/src/intl/de.d.ts.map +1 -0
  46. package/dist/src/intl/de.js +258 -0
  47. package/dist/src/intl/el.d.ts +117 -0
  48. package/dist/src/intl/el.d.ts.map +1 -0
  49. package/dist/src/intl/el.js +265 -0
  50. package/dist/src/intl/es.d.ts +117 -0
  51. package/dist/src/intl/es.d.ts.map +1 -0
  52. package/dist/src/intl/es.js +258 -0
  53. package/dist/src/intl/fa.d.ts +117 -0
  54. package/dist/src/intl/fa.d.ts.map +1 -0
  55. package/dist/src/intl/fa.js +258 -0
  56. package/dist/src/intl/fi.d.ts +117 -0
  57. package/dist/src/intl/fi.d.ts.map +1 -0
  58. package/dist/src/intl/fi.js +258 -0
  59. package/dist/src/intl/fil.d.ts +117 -0
  60. package/dist/src/intl/fil.d.ts.map +1 -0
  61. package/dist/src/intl/fil.js +258 -0
  62. package/dist/src/intl/fr.d.ts +117 -0
  63. package/dist/src/intl/fr.d.ts.map +1 -0
  64. package/dist/src/intl/fr.js +258 -0
  65. package/dist/src/intl/he.d.ts +117 -0
  66. package/dist/src/intl/he.d.ts.map +1 -0
  67. package/dist/src/intl/he.js +258 -0
  68. package/dist/src/intl/hi.d.ts +117 -0
  69. package/dist/src/intl/hi.d.ts.map +1 -0
  70. package/dist/src/intl/hi.js +258 -0
  71. package/dist/src/intl/hr.d.ts +117 -0
  72. package/dist/src/intl/hr.d.ts.map +1 -0
  73. package/dist/src/intl/hr.js +265 -0
  74. package/dist/src/intl/hu.d.ts +63 -0
  75. package/dist/src/intl/hu.d.ts.map +1 -0
  76. package/dist/src/intl/hu.js +204 -0
  77. package/dist/src/intl/id.d.ts +117 -0
  78. package/dist/src/intl/id.d.ts.map +1 -0
  79. package/dist/src/intl/id.js +258 -0
  80. package/dist/src/intl/index.d.ts +42 -0
  81. package/dist/src/intl/index.d.ts.map +1 -1
  82. package/dist/src/intl/index.js +42 -0
  83. package/dist/src/intl/it.d.ts +117 -0
  84. package/dist/src/intl/it.d.ts.map +1 -0
  85. package/dist/src/intl/it.js +258 -0
  86. package/dist/src/intl/ja.d.ts +117 -0
  87. package/dist/src/intl/ja.d.ts.map +1 -0
  88. package/dist/src/intl/ja.js +258 -0
  89. package/dist/src/intl/ko.d.ts +117 -0
  90. package/dist/src/intl/ko.d.ts.map +1 -0
  91. package/dist/src/intl/ko.js +258 -0
  92. package/dist/src/intl/ml.d.ts +117 -0
  93. package/dist/src/intl/ml.d.ts.map +1 -0
  94. package/dist/src/intl/ml.js +258 -0
  95. package/dist/src/intl/mr.d.ts +117 -0
  96. package/dist/src/intl/mr.d.ts.map +1 -0
  97. package/dist/src/intl/mr.js +258 -0
  98. package/dist/src/intl/ms.d.ts +117 -0
  99. package/dist/src/intl/ms.d.ts.map +1 -0
  100. package/dist/src/intl/ms.js +245 -0
  101. package/dist/src/intl/nb.d.ts +63 -0
  102. package/dist/src/intl/nb.d.ts.map +1 -0
  103. package/dist/src/intl/nb.js +191 -0
  104. package/dist/src/intl/nl.d.ts +117 -0
  105. package/dist/src/intl/nl.d.ts.map +1 -0
  106. package/dist/src/intl/nl.js +258 -0
  107. package/dist/src/intl/pa.d.ts +117 -0
  108. package/dist/src/intl/pa.d.ts.map +1 -0
  109. package/dist/src/intl/pa.js +258 -0
  110. package/dist/src/intl/pl.d.ts +117 -0
  111. package/dist/src/intl/pl.d.ts.map +1 -0
  112. package/dist/src/intl/pl.js +242 -0
  113. package/dist/src/intl/pt-BR.d.ts +117 -0
  114. package/dist/src/intl/pt-BR.d.ts.map +1 -0
  115. package/dist/src/intl/pt-BR.js +258 -0
  116. package/dist/src/intl/pt.d.ts +117 -0
  117. package/dist/src/intl/pt.d.ts.map +1 -0
  118. package/dist/src/intl/pt.js +246 -0
  119. package/dist/src/intl/ro.d.ts +117 -0
  120. package/dist/src/intl/ro.d.ts.map +1 -0
  121. package/dist/src/intl/ro.js +258 -0
  122. package/dist/src/intl/sk.d.ts +117 -0
  123. package/dist/src/intl/sk.d.ts.map +1 -0
  124. package/dist/src/intl/sk.js +244 -0
  125. package/dist/src/intl/sl.d.ts +117 -0
  126. package/dist/src/intl/sl.d.ts.map +1 -0
  127. package/dist/src/intl/sl.js +258 -0
  128. package/dist/src/intl/sv.d.ts +117 -0
  129. package/dist/src/intl/sv.d.ts.map +1 -0
  130. package/dist/src/intl/sv.js +258 -0
  131. package/dist/src/intl/sw.d.ts +63 -0
  132. package/dist/src/intl/sw.d.ts.map +1 -0
  133. package/dist/src/intl/sw.js +191 -0
  134. package/dist/src/intl/ta.d.ts +117 -0
  135. package/dist/src/intl/ta.d.ts.map +1 -0
  136. package/dist/src/intl/ta.js +258 -0
  137. package/dist/src/intl/te.d.ts +117 -0
  138. package/dist/src/intl/te.d.ts.map +1 -0
  139. package/dist/src/intl/te.js +258 -0
  140. package/dist/src/intl/th.d.ts +117 -0
  141. package/dist/src/intl/th.d.ts.map +1 -0
  142. package/dist/src/intl/th.js +258 -0
  143. package/dist/src/intl/tr.d.ts +117 -0
  144. package/dist/src/intl/tr.d.ts.map +1 -0
  145. package/dist/src/intl/tr.js +255 -0
  146. package/dist/src/intl/uk.d.ts +117 -0
  147. package/dist/src/intl/uk.d.ts.map +1 -0
  148. package/dist/src/intl/uk.js +258 -0
  149. package/dist/src/intl/ur.d.ts +117 -0
  150. package/dist/src/intl/ur.d.ts.map +1 -0
  151. package/dist/src/intl/ur.js +245 -0
  152. package/dist/src/intl/vi.d.ts +117 -0
  153. package/dist/src/intl/vi.d.ts.map +1 -0
  154. package/dist/src/intl/vi.js +255 -0
  155. package/dist/src/intl/zh-CN.d.ts +117 -0
  156. package/dist/src/intl/zh-CN.d.ts.map +1 -0
  157. package/dist/src/intl/zh-CN.js +258 -0
  158. package/dist/src/intl/zh-TW.d.ts +117 -0
  159. package/dist/src/intl/zh-TW.d.ts.map +1 -0
  160. package/dist/src/intl/zh-TW.js +258 -0
  161. package/dist/src/local-first/Owner.d.ts +156 -62
  162. package/dist/src/local-first/Owner.d.ts.map +1 -1
  163. package/dist/src/local-first/Owner.js +119 -20
  164. package/package.json +1 -1
  165. package/src/Function.ts +2 -0
  166. package/src/Http.ts +9 -0
  167. package/src/Object.ts +2 -0
  168. package/src/RefCount.ts +2 -0
  169. package/src/Relation.ts +4 -0
  170. package/src/Resource.ts +2 -0
  171. package/src/Result.ts +397 -560
  172. package/src/StackTrace.ts +2 -0
  173. package/src/Task.ts +1143 -1222
  174. package/src/Time.ts +2 -0
  175. package/src/Type.ts +1759 -794
  176. package/src/intl/_en.ts +497 -0
  177. package/src/intl/ar.ts +417 -0
  178. package/src/intl/bn.ts +486 -0
  179. package/src/intl/ca.ts +488 -0
  180. package/src/intl/cs.ts +95 -31
  181. package/src/intl/da.ts +488 -0
  182. package/src/intl/de.ts +488 -0
  183. package/src/intl/el.ts +494 -0
  184. package/src/intl/es.ts +488 -0
  185. package/src/intl/fa.ts +487 -0
  186. package/src/intl/fi.ts +487 -0
  187. package/src/intl/fil.ts +488 -0
  188. package/src/intl/fr.ts +488 -0
  189. package/src/intl/he.ts +486 -0
  190. package/src/intl/hi.ts +487 -0
  191. package/src/intl/hr.ts +494 -0
  192. package/src/intl/hu.ts +387 -0
  193. package/src/intl/id.ts +487 -0
  194. package/src/intl/index.ts +42 -0
  195. package/src/intl/it.ts +488 -0
  196. package/src/intl/ja.ts +488 -0
  197. package/src/intl/ko.ts +487 -0
  198. package/src/intl/ml.ts +487 -0
  199. package/src/intl/mr.ts +487 -0
  200. package/src/intl/ms.ts +410 -0
  201. package/src/intl/nb.ts +364 -0
  202. package/src/intl/nl.ts +488 -0
  203. package/src/intl/pa.ts +487 -0
  204. package/src/intl/pl.ts +450 -0
  205. package/src/intl/pt-BR.ts +487 -0
  206. package/src/intl/pt.ts +424 -0
  207. package/src/intl/ro.ts +488 -0
  208. package/src/intl/sk.ts +412 -0
  209. package/src/intl/sl.ts +487 -0
  210. package/src/intl/sv.ts +488 -0
  211. package/src/intl/sw.ts +324 -0
  212. package/src/intl/ta.ts +487 -0
  213. package/src/intl/te.ts +487 -0
  214. package/src/intl/th.ts +484 -0
  215. package/src/intl/tr.ts +487 -0
  216. package/src/intl/uk.ts +488 -0
  217. package/src/intl/ur.ts +410 -0
  218. package/src/intl/vi.ts +435 -0
  219. package/src/intl/zh-CN.ts +482 -0
  220. package/src/intl/zh-TW.ts +482 -0
  221. package/src/local-first/Owner.ts +156 -62
package/src/intl/fr.ts ADDED
@@ -0,0 +1,488 @@
1
+ /**
2
+ * Formatters for Evolu Type errors in French.
3
+ *
4
+ * @module
5
+ */
6
+
7
+ import { assertNonNullable } from "../Assert.ts";
8
+ import { safelyStringifyUnknownValue } from "../String.ts";
9
+ import type {
10
+ ArrayError,
11
+ Base64UrlError,
12
+ BetweenError,
13
+ CapitalizedError,
14
+ DateIsoError,
15
+ DateIsoFromDateError,
16
+ DecimalStringError,
17
+ DiscriminatedUnionError,
18
+ EvoluTypeError,
19
+ FiniteError,
20
+ GreaterThanError,
21
+ GreaterThanOrEqualToError,
22
+ InstanceOfError,
23
+ Int64Error,
24
+ Int64StringError,
25
+ IntError,
26
+ IdError,
27
+ JsonError,
28
+ JsonValueError,
29
+ LengthError,
30
+ LessThanError,
31
+ LessThanOrEqualToError,
32
+ LiteralError,
33
+ MaxLengthError,
34
+ MinLengthError,
35
+ MnemonicError,
36
+ MultipleOfError,
37
+ NegativeDecimalStringError,
38
+ NegativeError,
39
+ NameError,
40
+ NeverError,
41
+ NonNaNError,
42
+ NonNegativeDecimalStringError,
43
+ NonNegativeError,
44
+ NonPositiveDecimalStringError,
45
+ NonPositiveError,
46
+ ObjectError,
47
+ ObjectNotObjectError,
48
+ ObjectPropertyAccessError,
49
+ ObjectTagError,
50
+ ObjectUnexpectedPrototypeError,
51
+ PositiveDecimalStringError,
52
+ PositiveError,
53
+ RecordError,
54
+ RegexError,
55
+ SetError,
56
+ TableIdError,
57
+ TemplateLiteralError,
58
+ TrimmedError,
59
+ TupleElementsError,
60
+ TupleError,
61
+ TypeError,
62
+ TypeErrorFormatter,
63
+ TypeOfError,
64
+ UInt64Error,
65
+ UnionError,
66
+ } from "../Type.ts";
67
+
68
+ const formatTypeOfError = (
69
+ error: TypeOfError<
70
+ "String" | "Number" | "BigInt" | "Boolean" | "Symbol" | "Function"
71
+ >,
72
+ ): string => {
73
+ const typeOf = error.expected.toLowerCase();
74
+
75
+ return `La valeur ${safelyStringifyUnknownValue(error.value)} n’est pas un(e) ${typeOf}.`;
76
+ };
77
+
78
+ const formatPlainObjectRootError = (
79
+ reason:
80
+ ObjectNotObjectError["reason"] | ObjectUnexpectedPrototypeError["reason"],
81
+ ): string =>
82
+ reason.kind === "NotObject"
83
+ ? `La valeur ${safelyStringifyUnknownValue(reason.value)} n’est pas un objet.`
84
+ : "La valeur est un objet, mais la sortie Object doit être un objet simple ou avoir un prototype nul.";
85
+
86
+ /** Formats a NeverError in French. */
87
+ export const formatNeverError: TypeErrorFormatter<NeverError> = (error) =>
88
+ `La valeur ${safelyStringifyUnknownValue(error.value)} n’est pas valide pour le type Never.`;
89
+
90
+ /** Formats a String TypeOfError in French. */
91
+ export const formatStringError: TypeErrorFormatter<TypeOfError<"String">> =
92
+ formatTypeOfError;
93
+
94
+ /** Formats a TemplateLiteralError in French. */
95
+ export const formatTemplateLiteralError: TypeErrorFormatter<
96
+ TemplateLiteralError
97
+ > = (error) =>
98
+ `La valeur ${safelyStringifyUnknownValue(error.value)} ne correspond pas au littéral de modèle.`;
99
+
100
+ /** Formats a Number TypeOfError in French. */
101
+ export const formatNumberError: TypeErrorFormatter<TypeOfError<"Number">> =
102
+ formatTypeOfError;
103
+
104
+ /** Formats a BigInt TypeOfError in French. */
105
+ export const formatBigIntError: TypeErrorFormatter<TypeOfError<"BigInt">> =
106
+ formatTypeOfError;
107
+
108
+ /** Formats a Boolean TypeOfError in French. */
109
+ export const formatBooleanError: TypeErrorFormatter<TypeOfError<"Boolean">> =
110
+ formatTypeOfError;
111
+
112
+ /** Formats a Symbol TypeOfError in French. */
113
+ export const formatSymbolError: TypeErrorFormatter<TypeOfError<"Symbol">> =
114
+ formatTypeOfError;
115
+
116
+ /** Formats a Function TypeOfError in French. */
117
+ export const formatFunctionError: TypeErrorFormatter<TypeOfError<"Function">> =
118
+ formatTypeOfError;
119
+
120
+ /** Formats an EvoluTypeError in French. */
121
+ export const formatEvoluTypeError: TypeErrorFormatter<EvoluTypeError> = (
122
+ error,
123
+ ) =>
124
+ `La valeur ${safelyStringifyUnknownValue(error.value)} n’est pas un type Evolu.`;
125
+
126
+ /** Formats an ObjectTagError in French. */
127
+ export const formatObjectTagError: TypeErrorFormatter<ObjectTagError> = (
128
+ error,
129
+ ) =>
130
+ `La valeur ${safelyStringifyUnknownValue(error.value)} n’a pas l’étiquette d’objet attendue ${safelyStringifyUnknownValue(error.expected)}.`;
131
+
132
+ /** Formats an InstanceOfError in French. */
133
+ export const formatInstanceOfError: TypeErrorFormatter<InstanceOfError> = (
134
+ error,
135
+ ) =>
136
+ `La valeur ${safelyStringifyUnknownValue(error.value)} n’est pas une instance de ${error.constructorName}.`;
137
+
138
+ /** Formats a LiteralError in French. */
139
+ export const formatLiteralError: TypeErrorFormatter<LiteralError> = (error) =>
140
+ `La valeur ${safelyStringifyUnknownValue(error.value)} n’est pas strictement égale au littéral attendu : ${globalThis.String(error.expected)}.`;
141
+
142
+ /** Formats a UnionError in French. */
143
+ export const formatUnionError: TypeErrorFormatter<UnionError> = () =>
144
+ "La valeur ne correspond à aucune variante autorisée.";
145
+
146
+ /** Formats a DateIsoError in French. */
147
+ export const formatDateIsoError: TypeErrorFormatter<DateIsoError> = (error) =>
148
+ `La valeur ${safelyStringifyUnknownValue(error.value)} n’est pas une chaîne de date et d’heure ISO canonique.`;
149
+
150
+ /** Formats a DateIsoFromDateError in French. */
151
+ export const formatDateIsoFromDateError: TypeErrorFormatter<
152
+ DateIsoFromDateError
153
+ > = () => "La Date ne peut pas être représentée comme DateIso.";
154
+
155
+ /** Formats a DecimalStringError in French. */
156
+ export const formatDecimalStringError: TypeErrorFormatter<
157
+ DecimalStringError
158
+ > = (error) =>
159
+ `La valeur ${safelyStringifyUnknownValue(error.value)} doit être une chaîne décimale canonique.`;
160
+
161
+ /** Formats an Int64Error in French. */
162
+ export const formatInt64Error: TypeErrorFormatter<Int64Error> = (error) =>
163
+ `La valeur ${safelyStringifyUnknownValue(error.value)} n’est pas un entier signé 64 bits (Int64) valide.`;
164
+
165
+ /** Formats a UInt64Error in French. */
166
+ export const formatUInt64Error: TypeErrorFormatter<UInt64Error> = (error) =>
167
+ `La valeur ${safelyStringifyUnknownValue(error.value)} n’est pas un entier non signé 64 bits (UInt64) valide.`;
168
+
169
+ /** Formats an Int64StringError in French. */
170
+ export const formatInt64StringError: TypeErrorFormatter<Int64StringError> = (
171
+ error,
172
+ ) =>
173
+ `La valeur ${safelyStringifyUnknownValue(error.value)} n’est pas une chaîne Int64 valide.`;
174
+
175
+ /** Formats a CapitalizedError in French. */
176
+ export const formatCapitalizedError: TypeErrorFormatter<CapitalizedError> = (
177
+ error,
178
+ ) =>
179
+ `La valeur ${safelyStringifyUnknownValue(error.value)} doit commencer par une majuscule.`;
180
+
181
+ /** Formats a TrimmedError in French. */
182
+ export const formatTrimmedError: TypeErrorFormatter<TrimmedError> = (error) =>
183
+ `La valeur ${safelyStringifyUnknownValue(error.value)} ne doit pas avoir d’espaces au début ou à la fin.`;
184
+
185
+ /** Formats a MinLengthError in French. */
186
+ export const formatMinLengthError: TypeErrorFormatter<MinLengthError> = (
187
+ error,
188
+ ) =>
189
+ `La valeur ${safelyStringifyUnknownValue(error.value)} ne respecte pas la longueur minimale de ${error.min}.`;
190
+
191
+ /** Formats a MaxLengthError in French. */
192
+ export const formatMaxLengthError: TypeErrorFormatter<MaxLengthError> = (
193
+ error,
194
+ ) =>
195
+ `La valeur ${safelyStringifyUnknownValue(error.value)} dépasse la longueur maximale de ${error.max}.`;
196
+
197
+ /** Formats a LengthError in French. */
198
+ export const formatLengthError: TypeErrorFormatter<LengthError> = (error) =>
199
+ `La valeur ${safelyStringifyUnknownValue(error.value)} n’a pas la longueur requise de ${error.exact}.`;
200
+
201
+ /** Formats a RegexError in French. */
202
+ export const formatRegexError: TypeErrorFormatter<RegexError> = (error) =>
203
+ `La valeur ${safelyStringifyUnknownValue(error.value)} ne correspond pas à /${error.source}/${error.flags}.`;
204
+
205
+ /** Formats a Base64UrlError in French. */
206
+ export const formatBase64UrlError: TypeErrorFormatter<Base64UrlError> = (
207
+ error,
208
+ ) =>
209
+ `La valeur ${safelyStringifyUnknownValue(error.value)} n’est pas une chaîne Base64Url valide.`;
210
+
211
+ /** Formats a NameError in French. */
212
+ export const formatNameError: TypeErrorFormatter<NameError> = (error) =>
213
+ `La valeur ${safelyStringifyUnknownValue(error.value)} n’est pas un Name valide.`;
214
+
215
+ /** Formats a MnemonicError in French. */
216
+ export const formatMnemonicError: TypeErrorFormatter<MnemonicError> = (error) =>
217
+ `La valeur ${safelyStringifyUnknownValue(error.value)} n’est pas une phrase mnémonique BIP39 anglaise valide.`;
218
+
219
+ /** Formats an IdError in French. */
220
+ export const formatIdError: TypeErrorFormatter<IdError> = (error) =>
221
+ `La valeur ${safelyStringifyUnknownValue(error.value)} n’est pas un Id valide.`;
222
+
223
+ /** Formats a TableIdError in French. */
224
+ export const formatTableIdError: TypeErrorFormatter<TableIdError> = (error) =>
225
+ `La valeur ${safelyStringifyUnknownValue(error.value)} n’est pas un Id valide pour la table ${error.table}.`;
226
+
227
+ /** Formats a NonNegativeError in French. */
228
+ export const formatNonNegativeError: TypeErrorFormatter<NonNegativeError> = (
229
+ error,
230
+ ) =>
231
+ `La valeur ${safelyStringifyUnknownValue(error.value)} doit être positive ou nulle (>= 0).`;
232
+
233
+ /** Formats a NonNegativeDecimalStringError in French. */
234
+ export const formatNonNegativeDecimalStringError: TypeErrorFormatter<
235
+ NonNegativeDecimalStringError
236
+ > = (error) =>
237
+ `La valeur ${safelyStringifyUnknownValue(error.value)} doit être une chaîne décimale positive ou nulle.`;
238
+
239
+ /** Formats a PositiveError in French. */
240
+ export const formatPositiveError: TypeErrorFormatter<PositiveError> = (error) =>
241
+ `La valeur ${safelyStringifyUnknownValue(error.value)} doit être positive (> 0).`;
242
+
243
+ /** Formats a PositiveDecimalStringError in French. */
244
+ export const formatPositiveDecimalStringError: TypeErrorFormatter<
245
+ PositiveDecimalStringError
246
+ > = (error) =>
247
+ `La valeur ${safelyStringifyUnknownValue(error.value)} doit être une chaîne décimale positive.`;
248
+
249
+ /** Formats a NonPositiveError in French. */
250
+ export const formatNonPositiveError: TypeErrorFormatter<NonPositiveError> = (
251
+ error,
252
+ ) =>
253
+ `La valeur ${safelyStringifyUnknownValue(error.value)} doit être négative ou nulle (<= 0).`;
254
+
255
+ /** Formats a NonPositiveDecimalStringError in French. */
256
+ export const formatNonPositiveDecimalStringError: TypeErrorFormatter<
257
+ NonPositiveDecimalStringError
258
+ > = (error) =>
259
+ `La valeur ${safelyStringifyUnknownValue(error.value)} doit être une chaîne décimale négative ou nulle.`;
260
+
261
+ /** Formats a NegativeError in French. */
262
+ export const formatNegativeError: TypeErrorFormatter<NegativeError> = (error) =>
263
+ `La valeur ${safelyStringifyUnknownValue(error.value)} doit être négative (< 0).`;
264
+
265
+ /** Formats a NegativeDecimalStringError in French. */
266
+ export const formatNegativeDecimalStringError: TypeErrorFormatter<
267
+ NegativeDecimalStringError
268
+ > = (error) =>
269
+ `La valeur ${safelyStringifyUnknownValue(error.value)} doit être une chaîne décimale négative.`;
270
+
271
+ /** Formats an IntError in French. */
272
+ export const formatIntError: TypeErrorFormatter<IntError> = (error) =>
273
+ `La valeur ${safelyStringifyUnknownValue(error.value)} doit être un entier sûr.`;
274
+
275
+ /** Formats a GreaterThanError in French. */
276
+ export const formatGreaterThanError: TypeErrorFormatter<GreaterThanError> = (
277
+ error,
278
+ ) =>
279
+ `La valeur ${safelyStringifyUnknownValue(error.value)} doit être supérieure à ${error.min}.`;
280
+
281
+ /** Formats a GreaterThanOrEqualToError in French. */
282
+ export const formatGreaterThanOrEqualToError: TypeErrorFormatter<
283
+ GreaterThanOrEqualToError
284
+ > = (error) =>
285
+ `La valeur ${safelyStringifyUnknownValue(error.value)} doit être supérieure ou égale à ${error.min}.`;
286
+
287
+ /** Formats a LessThanError in French. */
288
+ export const formatLessThanError: TypeErrorFormatter<LessThanError> = (error) =>
289
+ `La valeur ${safelyStringifyUnknownValue(error.value)} doit être inférieure à ${error.max}.`;
290
+
291
+ /** Formats a LessThanOrEqualToError in French. */
292
+ export const formatLessThanOrEqualToError: TypeErrorFormatter<
293
+ LessThanOrEqualToError
294
+ > = (error) =>
295
+ `La valeur ${safelyStringifyUnknownValue(error.value)} doit être inférieure ou égale à ${error.max}.`;
296
+
297
+ /** Formats a NonNaNError in French. */
298
+ export const formatNonNaNError: TypeErrorFormatter<NonNaNError> = () =>
299
+ "La valeur ne doit pas être NaN.";
300
+
301
+ /** Formats a FiniteError in French. */
302
+ export const formatFiniteError: TypeErrorFormatter<FiniteError> = (error) =>
303
+ `La valeur ${safelyStringifyUnknownValue(error.value)} doit être finie.`;
304
+
305
+ /** Formats a MultipleOfError in French. */
306
+ export const formatMultipleOfError: TypeErrorFormatter<MultipleOfError> = (
307
+ error,
308
+ ) =>
309
+ `La valeur ${safelyStringifyUnknownValue(error.value)} doit être un multiple de ${error.divisor}.`;
310
+
311
+ /** Formats a BetweenError in French. */
312
+ export const formatBetweenError: TypeErrorFormatter<BetweenError> = (error) =>
313
+ `La valeur ${safelyStringifyUnknownValue(error.value)} doit être comprise entre ${error.min} et ${error.max}, inclus.`;
314
+
315
+ /** Formats an ArrayError in French. */
316
+ export const formatArrayError: TypeErrorFormatter<ArrayError> = (error) => {
317
+ if (error.reason.kind === "NotArray") {
318
+ return `La valeur ${safelyStringifyUnknownValue(error.reason.value)} n’est pas un tableau.`;
319
+ }
320
+ const issue = error.reason.issues[0];
321
+
322
+ switch (issue.kind) {
323
+ case "Hole":
324
+ return `L’élément du tableau à l’indice ${issue.index} est manquant.`;
325
+ case "Accessor":
326
+ return `L’élément du tableau à l’indice ${issue.index} doit être une propriété de données.`;
327
+ case "ExcessProperty":
328
+ return "Une propriété Array excédentaire n’est pas autorisée. Supprimez-la ou utilisez un autre Type.";
329
+ case "Element":
330
+ return `L’élément du tableau à l’indice ${issue.index} n’est pas valide.`;
331
+ }
332
+ };
333
+
334
+ /** Formats a SetError in French. */
335
+ export const formatSetError: TypeErrorFormatter<SetError> = (error) => {
336
+ if (error.reason.kind === "NotSet") {
337
+ return `La valeur ${safelyStringifyUnknownValue(error.reason.value)} n’est pas un Set.`;
338
+ }
339
+ if (error.reason.kind === "UnexpectedPrototype") {
340
+ return "La valeur est une instance d’une sous-classe de Set, mais la sortie Set doit être une instance directe de Set.";
341
+ }
342
+
343
+ const issue = error.reason.issues[0];
344
+
345
+ switch (issue.kind) {
346
+ case "ExcessProperty":
347
+ return `La propriété Set excédentaire ${safelyStringifyUnknownValue(issue.key)} n’est pas autorisée.`;
348
+ case "Element":
349
+ return `L’élément Set à l’indice ${issue.index} n’est pas valide.`;
350
+ }
351
+ };
352
+
353
+ /** Formats a TupleError in French. */
354
+ export const formatTupleError: TypeErrorFormatter<
355
+ TupleError | TupleElementsError<TypeError>
356
+ > = (error) => {
357
+ if (error.reason.kind === "NotArray") {
358
+ return `La valeur ${safelyStringifyUnknownValue(error.reason.value)} n’est pas un tuple.`;
359
+ }
360
+ if (error.reason.kind === "InvalidLength") {
361
+ return `Un Tuple doit contenir exactement ${error.reason.expected} éléments, mais la valeur en contient ${error.reason.actual}.`;
362
+ }
363
+
364
+ const issue = error.reason.issues[0];
365
+
366
+ switch (issue.kind) {
367
+ case "Hole":
368
+ return `L’élément Tuple à l’indice ${issue.index} est manquant.`;
369
+ case "Accessor":
370
+ return `L’élément Tuple à l’indice ${issue.index} doit être une propriété de données.`;
371
+ case "ExcessProperty":
372
+ return "Une propriété Tuple excédentaire n’est pas autorisée. Supprimez-la ou utilisez un autre Type.";
373
+ case "Element":
374
+ return `L’élément Tuple à l’indice ${issue.index} n’est pas valide.`;
375
+ }
376
+ };
377
+
378
+ /** Formats a RecordError in French. */
379
+ export const formatRecordError: TypeErrorFormatter<RecordError> = (error) => {
380
+ if (error.reason.kind === "NotRecord") {
381
+ return `La valeur ${safelyStringifyUnknownValue(error.reason.value)} n’est pas un Record.`;
382
+ }
383
+ if (error.reason.kind === "NotPlainRecord") {
384
+ return "La valeur est un objet, mais la sortie Record doit être un objet simple ou avoir un prototype nul.";
385
+ }
386
+
387
+ const issue = error.reason.issues[0];
388
+
389
+ switch (issue.kind) {
390
+ case "Key":
391
+ return `La clé de propriété ${safelyStringifyUnknownValue(issue.key)} n’est pas valide.`;
392
+ case "Value":
393
+ return `La valeur de la propriété ${safelyStringifyUnknownValue(issue.key)} n’est pas valide.`;
394
+ case "Accessor":
395
+ return `La propriété Record ${safelyStringifyUnknownValue(issue.key)} doit être une propriété de données.`;
396
+ case "NonEnumerable":
397
+ return `La propriété Record ${safelyStringifyUnknownValue(issue.key)} doit être énumérable.`;
398
+ case "Collision":
399
+ return `Les clés Record ${safelyStringifyUnknownValue(issue.previousKey)} et ${safelyStringifyUnknownValue(issue.key)} sont décodées en la même clé ${safelyStringifyUnknownValue(issue.outputKey)}.`;
400
+ }
401
+ };
402
+
403
+ /** Formats an ObjectError in French. */
404
+ export const formatObjectError: TypeErrorFormatter<ObjectError> = (error) => {
405
+ if (error.reason.kind !== "Properties") {
406
+ return formatPlainObjectRootError(error.reason);
407
+ }
408
+
409
+ const key = Reflect.ownKeys(error.reason.errors).at(0);
410
+ assertNonNullable(key);
411
+ const propertyError = error.reason.errors[key];
412
+ assertNonNullable(propertyError);
413
+
414
+ if (propertyError.type === "ObjectPropertyAccess") {
415
+ switch ((propertyError as ObjectPropertyAccessError).reason) {
416
+ case "Accessor":
417
+ return "Une propriété Object doit être une propriété de données. Convertissez les valeurs d’accesseur en données simples avant d’utiliser ce Type, ou utilisez un autre Type.";
418
+ case "NonEnumerable":
419
+ return "Une propriété Object doit être énumérable. Rendez-la énumérable ou utilisez un autre Type.";
420
+ }
421
+ }
422
+ if (propertyError.type === "ObjectMissingProperty") {
423
+ return `La propriété requise ${safelyStringifyUnknownValue(key)} est manquante.`;
424
+ }
425
+ if (typeof key === "symbol") {
426
+ return "La clé d’une propriété Object doit être une chaîne. Supprimez la propriété symbole ou utilisez un autre Type.";
427
+ }
428
+ if (propertyError.type === "ObjectExcessProperty") {
429
+ return `La propriété ${safelyStringifyUnknownValue(key)} n’est pas autorisée. Supprimez-la ou utilisez un autre Type.`;
430
+ }
431
+ return `La propriété ${safelyStringifyUnknownValue(key)} n’est pas valide.`;
432
+ };
433
+
434
+ /** Formats a DiscriminatedUnionError in French. */
435
+ export const formatDiscriminatedUnionError: TypeErrorFormatter<
436
+ DiscriminatedUnionError
437
+ > = (error) => {
438
+ switch (error.reason.kind) {
439
+ case "Object":
440
+ return formatPlainObjectRootError(error.reason.error.reason);
441
+ case "PropertyAccess": {
442
+ const property = `La propriété discriminante ${safelyStringifyUnknownValue(error.reason.key)}`;
443
+ if (error.reason.reason === "Accessor") {
444
+ return `${property} doit être une propriété de données.`;
445
+ }
446
+ if (error.reason.reason === "Inherited") {
447
+ return `${property} doit être une propriété propre.`;
448
+ }
449
+ return `${property} doit être énumérable.`;
450
+ }
451
+ case "Discriminator":
452
+ return `La propriété discriminante ${safelyStringifyUnknownValue(error.reason.key)} a une valeur inattendue ${safelyStringifyUnknownValue(error.reason.value)}.`;
453
+ case "Member":
454
+ return `La variante sélectionnée ${safelyStringifyUnknownValue(error.reason.discriminator)} n’est pas valide.`;
455
+ }
456
+ };
457
+
458
+ /** Formats a JsonValueError in French. */
459
+ export const formatJsonValueError: TypeErrorFormatter<JsonValueError> = (
460
+ error,
461
+ ) => {
462
+ const issue = error.reason.issues[0];
463
+
464
+ switch (issue.kind) {
465
+ case "InvalidType":
466
+ return `La valeur ${safelyStringifyUnknownValue(issue.value)} n’est pas une valeur JSON.`;
467
+ case "NonFiniteNumber":
468
+ return "Un nombre JSON doit être fini.";
469
+ case "UnexpectedPrototype":
470
+ return "La valeur est un objet, mais un objet JsonValue doit être un objet simple ou avoir un prototype nul.";
471
+ case "Accessor":
472
+ return "Une propriété JSON doit être une propriété de données. Convertissez les valeurs d’accesseur en données simples avant d’utiliser ce Type, ou utilisez un autre Type.";
473
+ case "NonEnumerable":
474
+ return "Une propriété d’objet JSON doit être énumérable. Supprimez-la ou utilisez un autre Type.";
475
+ case "SymbolProperty":
476
+ return "La clé d’une propriété d’objet JSON doit être une chaîne. Supprimez la propriété symbole ou utilisez un autre Type.";
477
+ case "Hole":
478
+ return "Un élément de tableau JSON est manquant.";
479
+ case "ExcessProperty":
480
+ return "Une propriété de tableau JSON excédentaire n’est pas autorisée. Supprimez-la ou utilisez un autre Type.";
481
+ case "CircularReference":
482
+ return "Un JsonValue ne doit pas contenir de références circulaires.";
483
+ }
484
+ };
485
+
486
+ /** Formats a JsonError in French. */
487
+ export const formatJsonError: TypeErrorFormatter<JsonError> = (error) =>
488
+ `La valeur ${safelyStringifyUnknownValue(error.value)} ne peut pas être analysée comme un JsonValue.`;