guillotinaweb / ngx-schema-form

HTML form generation based on JSON Schema
MIT License
485 stars 174 forks source link

VisibleIf - empty object check #420

Closed daniele-pecora closed 2 years ago

daniele-pecora commented 2 years ago

The current implemented check of an empty object doesn't recognize an empty object that inherits from prototype.

Bildschirmfoto 2021-12-17 um 17 24 32

This seems to being added with commit https://github.com/guillotinaweb/ngx-schema-form/pull/415/commits/ccb841a7866ca77486e4293418a3f8b6e5834787

Since ...

var a={}
var valid = a !== {}

... valid will be true here, so this can't be used as comparison for an empty object.

Instead the properties must be checked explicit for existence.

eg.

var a={}
var valid = (value)=>{
for(var i in value) return false; 
 return true;
}