DEV Community

Discussion on: DO NOT trust your frontend validators

Collapse
 
mcsee profile image
Maxi Contieri

Objects should always valid

No matter if they come from the frontend. backedn api, imports etc
Business rules should be in the object itself

Collapse
 
polterguy profile image
Thomas Hansen

Assuming you believe in OO ofcโ€ฆ ๐Ÿ˜‰

Collapse
 
mcsee profile image
Maxi Contieri

I am guilty as charged

Collapse
 
aarone4 profile image
Aaron Reese

Only if you are really specific about your objects. E.g. a customer object can't have an email property as a string, it would need to be a type of email object because email needs special validation and is used also on suppliers, users, prospects etc. Before long you have a horrible DX where you are constantly writing order.dispatch.shipaddress.zipcode, order.dispatch.shipaddress.country