Closed fgnm closed 4 years ago
The framework validates received fields only with PATCH
method. So your behaviour is correct. You can easily check the keys:
schema.setPatch(function($) {
if (!$.keys.length) {
$.invalid('invalid');
return;
}
// do something
});
Again:
PATCH
method allows you to violate rules in schema validationPATCH
are validates fields which are really receivedrequired
fields is optional, but if they are exist then are requiredThank you as always for the clear explanation :smile:
I've noticed that automatic schema validation does not works if I use
PATCH
as HTTP method. For example:Return
success
even if I requestcurl -X PATCH -H 'Content-Type: application/json' -i 'http://api.localhost:8000/v1/user/patch' --data '{ }'
In this case the body is empty and noregion
field is provided, but the schema does not validate. If I use thePOST
method instead ofPATCH
it works as expected and returns an error.