@maestro-js/form 1.0.0-alpha.1 → 1.0.0-alpha.10
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/dist/index.d.ts +3 -2
- package/dist/index.js +6 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -110,7 +110,8 @@ type ParseFormDataResult<T> = {
|
|
|
110
110
|
};
|
|
111
111
|
interface ParseFormDataOptions<T> {
|
|
112
112
|
handleFile?(file: File, path: string, data: T): Promise<string>;
|
|
113
|
-
|
|
113
|
+
validateLibraryOptions?: Record<string, unknown> | undefined;
|
|
114
|
+
jsonSchemaLibraryOptions?: Record<string, unknown> | undefined;
|
|
114
115
|
}
|
|
115
116
|
declare function parseFormDataClientSide<T>(schema: StandardSchema<T>, formData: FormData, options?: ParseFormDataOptions<T>): ParseFormDataResult<T> & {
|
|
116
117
|
fileEntries: FoundFile[];
|
|
@@ -180,4 +181,4 @@ declare const HeadlessForm: (<As extends React.ElementType = "form">(props: {
|
|
|
180
181
|
composeValidators: typeof composeValidators;
|
|
181
182
|
};
|
|
182
183
|
|
|
183
|
-
export { HeadlessForm, type HeadlessFormProps, type ValidationFunction, type ValidationResult };
|
|
184
|
+
export { HeadlessForm, type HeadlessFormProps, type ParseFormDataOptions, type ParseFormDataResult, type StandardSchema, type ValidationFunction, type ValidationResult };
|
package/dist/index.js
CHANGED
|
@@ -775,10 +775,13 @@ function formPathsMatch(path1, path2) {
|
|
|
775
775
|
// src/standard-schema-helpers.ts
|
|
776
776
|
function parseFormDataClientSide(schema, formData, options) {
|
|
777
777
|
const formId = formData.get("__formId");
|
|
778
|
-
const jsonSchemaParsed = parseJsonSchemaFormData(
|
|
778
|
+
const jsonSchemaParsed = parseJsonSchemaFormData(
|
|
779
|
+
schema["~standard"].jsonSchema.input({ target: "openapi-3.0", libraryOptions: options?.jsonSchemaLibraryOptions }),
|
|
780
|
+
formData
|
|
781
|
+
);
|
|
779
782
|
const files = findFiles(jsonSchemaParsed);
|
|
780
783
|
files.forEach((f) => set2(jsonSchemaParsed, f.path.join("."), "https://fakeurlforformuploading.com"));
|
|
781
|
-
const safeParsed = schema["~standard"].validate(jsonSchemaParsed, options);
|
|
784
|
+
const safeParsed = schema["~standard"].validate(jsonSchemaParsed, { libraryOptions: options?.validateLibraryOptions });
|
|
782
785
|
if (isPromise(safeParsed)) {
|
|
783
786
|
throw new Error("Async validation not supported");
|
|
784
787
|
}
|
|
@@ -813,7 +816,7 @@ async function parseFormData(schema, formData, options) {
|
|
|
813
816
|
);
|
|
814
817
|
const obj2 = { ...parsed1.data };
|
|
815
818
|
uploadedFiles.forEach(({ key, value }) => set2(obj2, key, value));
|
|
816
|
-
const safeParsed2 = schema["~standard"].validate(obj2, options);
|
|
819
|
+
const safeParsed2 = schema["~standard"].validate(obj2, { libraryOptions: options?.validateLibraryOptions });
|
|
817
820
|
if (isPromise(safeParsed2)) {
|
|
818
821
|
throw new Error("Async validation not supported");
|
|
819
822
|
}
|