test: json field e2e and int

This commit is contained in:
Dan Ribbens
2022-12-23 17:45:22 -05:00
parent 73b8ba3d4a
commit abaa22950c
3 changed files with 57 additions and 0 deletions

View File

@@ -104,6 +104,14 @@ export const promise = async ({
valueToValidate = siblingData[field.name];
}
if (field.type === 'json' && typeof siblingData[field.name] === 'string') {
try {
JSON.parse(siblingData[field.name] as string);
} catch (e) {
field.jsonError = e;
}
}
const validationResult = await field.validate(valueToValidate, {
...field,
data: merge(doc, data, { arrayMerge: (_, source) => source }),