-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 objects when initialized #2032
Comments
This has always been the case due to the initial design of troposphere allowing for a more getter/setter interface:
But this does bring up the point on whether validation could be done at object creation or when added to a template. |
Hi Mark, I looked through the code and found there is a method of the def validate(self) -> None:
pass but there is a different method called def _validate_props(self) -> None:
for k, (_, required) in self.props.items():
if required and k not in self.properties:
rtype = getattr(self, "resource_type", type(self))
title = getattr(self, "title")
msg = "Resource %s required in type %s" % (k, rtype)
if title:
msg += " (title: %s)" % title
raise ValueError(msg) I see the I don't know, just an idea. Will work with the |
Opening for @MattJaccino based on questions in another issue.
Not specific to WAFv2, but one thing that did strike me as odd was that resource objects can be successfully initialized without all of the required properties being given. I thought I remembered it erroring out in situations like that, or am I missing something. ?
I thought with a property defined as
if you tried to initialize without defining Prop1, it would throw some kind of exception. It seems like you can initialize resource objects without including all of the required properties, or with none at all.
Was this always the case, or did something change? If not, could that potentially be a feature request?
The text was updated successfully, but these errors were encountered: