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:
+4
-2
@@ -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\\""]"`;
|
||||
|
||||
+1
-1
@@ -149,7 +149,7 @@ export const failingCreateInputByFieldMetadataType: {
|
||||
[FieldMetadataType.RAW_JSON]: [
|
||||
{
|
||||
input: {
|
||||
rawJsonField: 'not-a-json',
|
||||
rawJsonField: 'not-a-stringified-json',
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
+8
@@ -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]: [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user