Validation on type face problem when binding data from DB null.
The submit /post will not fire due to validation failed but if user simple enter some text and then erase it in the text box, the validation passed.
Indeed null is a specific jsonschema type and not a string. Try casting your null into undefined to mark the field unfilled.
@n1k0 null is jasonschma type?
I try set "type": "null" as below but i got "Unsupported field schema { "type": "null"..."
"ID_NUMBER": {
"type": "null",
"title": "IC Number",
"pattern": "^$|^((\d{2}((0[13578]|1[02])(0[1-9]|[12]\d|3[01])|(0[13456789]|1[012])(0[1-9]|[12]\d|30)|02(0[1-9]|1\d|2[0-8])))|([02468][048]|[13579][26])0229)\d{2}\d{4}$",
"messages": {
pattern: "Invalid ic number format.",
}
The null jsonschema type only accepts null values (and supporting a null field wouldn't make any sense in a HTML forms library). You seem to be after a nullable string type, eg. ["string", "null"] (where a provided value could either be a string or null), but this isn't supported in this lib (see #282).
Still, turning your null DB values into js undefined ones should solve your initial use case here.
Thoughts on a form option to cast nulls to undefined? For now I filter using the transformError prop - errors.filter(error => !!error.instance)
I think there should be some supported solution for this, because null is a valid value if the field is not marked as required.
null is a valid value if the field is not marked as required.
If a field is not required, the object property should either be missing or set to the expected type:

So, I'm doing a PATCH operation from all the field values. If I set nulls as undefined, I'm bypassing the validation but... I'm losing the fields for patching and the server thinks I'm just not sending any value for modification.
This is a client side form library. What you send to your server should probably be post-processed. Also, if your server expects null or string values for example, you should type your schema accordingly, with a composite schema type like ["null", "string"], though that is not supported by this lib yet.
But maybe someone wants to work on a patch?
Derived from @1dolinski's comment, I'm currently filtering errors like this:
transformErrors={errors => errors.filter(error => error.hasOwnProperty('instance'))}
If I have some time left towards the end of the week, I'll look into creating a PR to support ["null", "string"].
What was the outcome of this thread? Is the expectation to use
transformErrors={errors => errors.filter(error => error.hasOwnProperty('instance'))}
or is there support for ["null","string"] types?
+1 for support for ["null","string"]
+1 for support for ["null","string"]
["null", "string"] seems like a duplicate of #465.
Most helpful comment
I think there should be some supported solution for this, because
nullis a valid value if the field is not marked as required.