I think it depends on what you want to achieve, you could split it to multiple classes and have them inherit each other depending on what you want to achieve
I have a Validator class which is nothing but the base class having methods like validate(), and some root properties which will be needed for processing. Then we will have different classes like Type Validator which will have methods validate types like isString, isInt, etc. Then we will have classes like DB Validator which will have methods like isDuplicateUser, etc.
In order to use this Validator I will import and call chained methods like Validator().isString().isDuplicate().validate("username")@nedsoft
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
How can we decompose this into multiple classes? @nedsoft
I think it depends on what you want to achieve, you could split it to multiple classes and have them inherit each other depending on what you want to achieve
I have a Validator class which is nothing but the base class having methods like validate(), and some root properties which will be needed for processing. Then we will have different classes like Type Validator which will have methods validate types like isString, isInt, etc. Then we will have classes like DB Validator which will have methods like isDuplicateUser, etc.
In order to use this Validator I will import and call chained methods like
Validator().isString().isDuplicate().validate("username")
@nedsoft