Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider using mixins for common methods in the Type classes #197

Open
mindjuice opened this issue Mar 12, 2015 · 0 comments
Open

Consider using mixins for common methods in the Type classes #197

mindjuice opened this issue Mar 12, 2015 · 0 comments
Labels

Comments

@mindjuice
Copy link
Contributor

The Type classes have many methods which are identical except for the class name before .prototype.

To keep the code more DRY, it would be nice to have these in their own file and include them as mixins for the Type classes (e.g., TypeString, TypeBoolean, etc.).

Some of the methods ripe for extraction include:

  • _getDefaultFields()
  • validator()
  • default()
  • options()
  • required()
  • optional()
  • validate() - The first several lines of this method could call a common mixin method
  • checkType() - This may be renamed/refactored soon, so the name may not be right

Alternatively, if mixins are not desired, there could be a Type base class that all other types inherit from.

@neumino neumino added the hygiene label Aug 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants