hashicorp / terraform-plugin-framework-validators

Common Use Case Validators for terraform-plugin-framework
Mozilla Public License 2.0
25 stars 12 forks source link

feat(stringvalidator): support validating time durations #214

Closed NikolaLohinski closed 5 months ago

NikolaLohinski commented 6 months ago

Import logic from https://github.com/hashicorp/terraform-plugin-framework-timeouts/blob/main/internal/validators/timeduration.go which can not be imported and used elswhere because it is an internal package.

I also changed the name from TimeDuration to just Duration as there no ambiguity with the shorter name.

hashicorp-cla-app[bot] commented 6 months ago

CLA assistant check
All committers have signed the CLA.

bflad commented 5 months ago

Hi @NikolaLohinski 👋 Thank you for also raising this.

On the surface this is a valid enhancement, however as the README notes:

This Go module is not intended to define all possible validations. In particular, many validators that relate to specific string formats, encodings, and other specifics should instead be implemented separately in custom attribute types ...

Without this design boundary, this Go module could become a catch-all for every possible string validation, which is not intended. Given that Go time.Duration strings are a specific string format and that terraform-plugin-framework-timetypes v0.4.0 will include your contributed timetypes.GoDuration types, I'm going to close this particular validator contribution. If you want to discuss this design position further, please create a new issue to start a discussion.

Thanks again though!

NikolaLohinski commented 5 months ago

Hi @bflad

Sounds fair to me. Thanks for taking the time to look review my PR.

Cheers