divnix / POP

Pure Object Prototypes
MIT License
20 stars 1 forks source link

type check properties #4

Open Pacman99 opened 2 years ago

Pacman99 commented 2 years ago

Best idea I've come up with to do this is to have yants export a function that generates a type checking pop. This pop will simply have an extension that does nothing but type check a series of values. If there are any problems, yants check functions will throw errors, otherwise the extension can just return an empty attrset. This could be implemented in yants itself.

blaggacao commented 2 years ago

yants already has nestable struct validation, is that what we'd be looking at?

Pacman99 commented 2 years ago

Yeah exactly, I don't think pop or yants really has to be changed for this. You can do this manually already by creating a pop that's extension type checks super and just returns back everything as the same. Then that type-checking pop can be a super for another pop where you want attributes type checked.

We can make a convenience function to create such a pop by passing it a yants struct.