You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
I am playing around with the json schema examples(https://formly.dev/docs/examples/advanced/json-schema) and realised the schema depedency example with bootstrap does not set validation on the field credit_card correctly when I clear the input after typing in a value. This field is optional. I suspect the validator for number type is active.
I have tried the react version of the library on https://rjsf-team.github.io/react-jsonschema-form/ and it works as intended in that when I clear the credit_card field, the form is valid again. As soon as I type a value and clears it, formly shows a validation error. Here is the active validator:
({
value
})=>{if(value===void0){returntrue;}if(value===null&&types.indexOf("null")!==-1){returntrue;}switch(types[0]){case"null": {returntypeofvalue===null;}case"string": {returntypeofvalue==="string";}case"integer": {returnisInteger(value);}case"number": {returntypeofvalue==="number";}case"object": {returnisObject(value);}case"array": {returnArray.isArray(value);}}returntrue;}
is there a better way to deal with nullable values which are not required when validating?
The text was updated successfully, but these errors were encountered:
A work around would be to extend formlyJsonschema.toFieldConfig
Chalolennox
changed the title
JSON Schema example with dependecies does not reset validation
Default JSON Schema type validation does not take to account whether a field is required
Apr 24, 2024
Description
I am playing around with the json schema examples(https://formly.dev/docs/examples/advanced/json-schema) and realised the schema depedency example with bootstrap does not set validation on the field credit_card correctly when I clear the input after typing in a value. This field is optional. I suspect the validator for number type is active.
Minimal Reproduction
I have tried the react version of the library on https://rjsf-team.github.io/react-jsonschema-form/ and it works as intended in that when I clear the credit_card field, the form is valid again. As soon as I type a value and clears it, formly shows a validation error. Here is the active validator:
is there a better way to deal with nullable values which are not required when validating?
The text was updated successfully, but these errors were encountered: