Fix raw json validation (#15931)

Before validation in common layer, stringified json were accepted in raw
json field. Fix regression

related to
https://discord.com/channels/1130383047699738754/1130383048173682821/1440723288090218636
This commit is contained in:
Etienne
2025-11-19 19:05:02 +01:00
committed by GitHub
parent 0223851620
commit 674ddbd525
7 changed files with 54 additions and 10 deletions
@@ -1,5 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Create input validation - RAW_JSON Gql create input - failure RAW_JSON - should fail with : {"rawJsonField":"not-a-json"} 1`] = `"Invalid object value 'not-a-json' for field "rawJsonField""`;
exports[`Create input validation - RAW_JSON Rest create input - failure RAW_JSON - should fail with : {"rawJsonField":"not-a-json"} 1`] = `"["Invalid object value 'not-a-json' for field \\"rawJsonField\\""]"`;
exports[`Create input validation - RAW_JSON Gql create input - failure RAW_JSON - should fail with : {"rawJsonField":"not-a-stringified-json"} 1`] = `"Invalid JSON string value 'not-a-stringified-json' for field "rawJsonField""`;
exports[`Create input validation - RAW_JSON Rest create input - failure RAW_JSON - should fail with : {"rawJsonField":"not-a-stringified-json"} 1`] = `"["Invalid JSON string value 'not-a-stringified-json' for field \\"rawJsonField\\""]"`;
@@ -149,7 +149,7 @@ export const failingCreateInputByFieldMetadataType: {
[FieldMetadataType.RAW_JSON]: [
{
input: {
rawJsonField: 'not-a-json',
rawJsonField: 'not-a-stringified-json',
},
},
],
@@ -145,6 +145,14 @@ export const successfulCreateInputByFieldMetadataType: {
return record.rawJsonField === null;
},
},
{
input: {
rawJsonField: '{"key": "value"}',
},
validateInput: (record: Record<string, any>) => {
return record.rawJsonField.key === 'value';
},
},
],
[FieldMetadataType.ARRAY]: [
{