mirror of
https://github.com/strapi/strapi.git
synced 2025-12-24 21:54:24 +00:00
fix: checks
This commit is contained in:
parent
0faf896735
commit
b5354baf37
@ -34,13 +34,7 @@
|
||||
"pluginOptions": {}
|
||||
},
|
||||
"priceRange": {
|
||||
"enum": [
|
||||
"very_cheap",
|
||||
"cheap",
|
||||
"average",
|
||||
"expensive",
|
||||
"very_expensive"
|
||||
],
|
||||
"enum": ["very_cheap", "cheap", "average", "expensive", "very_expensive"],
|
||||
"type": "enumeration",
|
||||
"pluginOptions": {
|
||||
"i18n": {
|
||||
|
||||
@ -345,7 +345,13 @@ const Form = React.forwardRef<HTMLFormElement, FormProps>(
|
||||
.filter((el) => el.selected)
|
||||
.map((el) => el.value);
|
||||
} else {
|
||||
val = value;
|
||||
// NOTE: reset value to null so it failes required checks.
|
||||
// The API only considers a required field invalid if the value is null|undefined, to differentiate from min 1
|
||||
if (value === '') {
|
||||
val = null;
|
||||
} else {
|
||||
val = value;
|
||||
}
|
||||
}
|
||||
|
||||
if (field) {
|
||||
|
||||
@ -77,6 +77,14 @@ describe('useDocument', () => {
|
||||
id: 1,
|
||||
postal_code: 'N2',
|
||||
notrepeat_req: {},
|
||||
repeat_req_min: [
|
||||
{
|
||||
name: 'toto',
|
||||
},
|
||||
{
|
||||
name: 'toto',
|
||||
},
|
||||
],
|
||||
city: 'London',
|
||||
repeat_req: [
|
||||
{
|
||||
@ -98,6 +106,14 @@ describe('useDocument', () => {
|
||||
name: 'toto',
|
||||
},
|
||||
],
|
||||
repeat_req_min: [
|
||||
{
|
||||
name: 'toto',
|
||||
},
|
||||
{
|
||||
name: 'toto',
|
||||
},
|
||||
],
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
{
|
||||
|
||||
@ -261,11 +261,7 @@ type ValidationFn = (
|
||||
options: ValidationOptions
|
||||
) => <TSchema extends AnySchema>(schema: TSchema) => TSchema;
|
||||
|
||||
const addNullableValidation: ValidationFn = (attribute) => (schema) => {
|
||||
if (attribute.required) {
|
||||
return schema;
|
||||
}
|
||||
|
||||
const addNullableValidation: ValidationFn = () => (schema) => {
|
||||
return nullableSchema(schema);
|
||||
};
|
||||
|
||||
|
||||
@ -224,7 +224,9 @@ const createDzValidator =
|
||||
updatedAttribute,
|
||||
});
|
||||
|
||||
validator = addMinMax(validator, { attr, updatedAttribute });
|
||||
if (!isDraft) {
|
||||
validator = addMinMax(validator, { attr, updatedAttribute });
|
||||
}
|
||||
|
||||
return validator;
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user