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

hcldec: add ValidateSpec #387

Merged
merged 1 commit into from
Jun 4, 2020
Merged

hcldec: add ValidateSpec #387

merged 1 commit into from
Jun 4, 2020

Conversation

vancluever
Copy link
Contributor

This adds ValidateFuncSpec, a new decoder Spec that allows one to add
custom validations to work with values at decode-time.

The validation is run on the value after the wrapped spec is applied to
the expression in question. Diagnostics are expected to be returned,
with the author having flexibility over whether or not they want to
specify a range; if one is not supplied, the range of the wrapped
expression is used.

Copy link
Contributor

@apparentlymart apparentlymart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! The approach here seems fine to me. I've left some feedback inline about some minor things, but the approval is intended to mean that I'm fine with moving straight to merge without another round of reviewing unless you want to discuss that feedback further.

hcldec/spec.go Outdated Show resolved Hide resolved
hcldec/spec.go Outdated Show resolved Hide resolved
@vancluever vancluever changed the title hcldec: add ValidateFuncSpec hcldec: add ValidateSpec Jun 4, 2020
This adds ValidateSpec, a new decoder Spec that allows one to add
custom validations to work with values at decode-time.

The validation is run on the value after the wrapped spec is applied to
the expression in question. Diagnostics are expected to be returned,
with the author having flexibility over whether or not they want to
specify a range; if one is not supplied, the range of the wrapped
expression is used.
@vancluever vancluever force-pushed the hcldec-add-validatefuncspec branch from f12e44b to 9c4784b Compare June 4, 2020 21:26
@vancluever
Copy link
Contributor Author

Done deal! Will be merging shortly 🙂

@vancluever vancluever merged commit 919ba77 into hcl2 Jun 4, 2020
@azr azr deleted the hcldec-add-validatefuncspec branch June 5, 2020 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants