Jonathan B
Jonathan B

Reputation: 169

Question about objects

Hey guys, i'm having some trouble with this:

In the object "consumer" i need to do a validation for the property Nit.

But i don't know where to put this validation.
Do i have to put it where i set the value,
In a public function to validate the content before setting the value,
or a method inside the object "validateNit"

I'm still learning and i have that doubt.

Ty so much for your help, and sorry about the crappy English.

Upvotes: 0

Views: 71

Answers (1)

jcomeau_ictx
jcomeau_ictx

Reputation: 38412

if the property is set just once on initialization, then validate it during object initialization, with a method validateNit. if it can be set/modified at any time with, say, a setNit(newNit) method, you can call validateNit() from setNit().

Upvotes: 1

Related Questions