-
Notifications
You must be signed in to change notification settings - Fork 103
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
Validate and raise error for unsupported colors #64
Validate and raise error for unsupported colors #64
Conversation
I'm going to hold off on merging until I can confirm that this doesn't conflict with internal testing. |
# Set the color but validate it | ||
def color=(hex) | ||
unless Type::Color::VALID_COLORS.include?(hex.to_s.downcase) | ||
raise ArgumentError, "Unable to set color to an invalid color.\nUse one of #{Type::Color::VALID_COLORS}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've been using a style like Type::Color.constants internally to do similar things. Allows you to avoid storing it as a separate value, and if a new constant is added, it gets picked up automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. 👍 I'm used to doing the same, but wasn't sure how it's handled in here.
@mdaines-r7 Understood. Fine by me. |
Validate and raise error for unsupported colors
Update
Nexpose::Tag
to respect Nexpose's allowed tag color values.