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

Support parameter-based validator interfaces <Type>ParameterValidator #235

Closed
shrsr opened this issue Sep 24, 2024 · 5 comments · Fixed by #238
Closed

Support parameter-based validator interfaces <Type>ParameterValidator #235

shrsr opened this issue Sep 24, 2024 · 5 comments · Fixed by #238
Labels
bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request
Milestone

Comments

@shrsr
Copy link

shrsr commented Sep 24, 2024

Module version

github.com/hashicorp/terraform-plugin-framework v1.10.0

The following snippet in the documentation https://github.com/hashicorp/terraform-plugin-framework/blob/v1.10.0/website/docs/plugin/framework/validation.mdx under the section Parameter Validation doesn't work as expected.

// Typically within the function.Definition for a function.
function.StringParameter{
    // ... other Parameter configuration ...

    Validators: []function.StringParameterValidator{
        stringvalidator.LengthBetween(10, 256),
    },
},

Actual Behavior

Error Message:
cannot use stringvalidator.LengthBetween() (value of type validator.String) as function.StringParameterValidator value in array or slice literal: validator.String does not implement function.StringParameterValidator (missing method ValidateParameterString)

Additionally, I would like to know if there are any plans to support functions under stringvalidator in the function.StringParameter in the future?

@shrsr shrsr added the bug Something isn't working label Sep 24, 2024
@austinvalle
Copy link
Member

Hey there @shrsr 👋🏻, thanks for reporting the issue.

I don't think we created a GH issue for it, but I think the original plan after hashicorp/terraform-plugin-framework#894 was to implement the new function parameter validators for all the appropriate terraform-plugin-framework-validators implementations.

I'm going to move this GH issue to the validators repo as our intention is to implement that new interface and support parameter-based validation for all the type packages (stringvalidator, int64validator, etc.)

@austinvalle austinvalle transferred this issue from hashicorp/terraform-plugin-framework Sep 25, 2024
@austinvalle austinvalle changed the title stringvalidator.LengthBetween() in Documentation Example Not Working as expected Support parameter-based validator interfaces <Type>ParameterValidator Sep 25, 2024
@austinvalle austinvalle added documentation Improvements or additions to documentation enhancement New feature or request labels Sep 25, 2024
@shrsr
Copy link
Author

shrsr commented Sep 27, 2024

@austinvalle Thank you for the reply.
Will the above mentioned snippet in the docs still be present because it doesn't currently work?

@austinvalle
Copy link
Member

I think we'd opt to just fix the root issue of the validation implementation not being finished (this issue), which when released would make the documentation valid. Rather than adjusting the docs, fixing this issue, then re-adjusting the docs back. Additionally, our documentation releases are linked to Go module releases and we don't have any upcoming terraform-plugin-framework releases to link to ATM.

@shrsr
Copy link
Author

shrsr commented Oct 1, 2024

Thanks!

@austinvalle
Copy link
Member

Most of the validators have been updated to support function validators with the latest release v0.14.0.

There are some remaining ones like All/Any that can be tracked in #239

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
2 participants