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

Define how to express uri and email forms (Renamed) #62

Closed
mattfarina opened this issue Apr 6, 2018 · 5 comments
Closed

Define how to express uri and email forms (Renamed) #62

mattfarina opened this issue Apr 6, 2018 · 5 comments
Assignees

Comments

@mattfarina
Copy link

Is there a way to specify validation for things just as email and URL/URI?

@pwittrock
Copy link
Contributor

@mattfarina Good question. This is all done through the openAPI v3 validation supported by CRDs. Do you know what the CRD validation supports? I may need to add an extra hook.

I am not totally clear from this document about what validation is supported by openAPI v3: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md. It mentions uuid and email as formats but says they are undefined by the spec.

If nothing else, you may be able to use "Pattern".

@mattfarina
Copy link
Author

@pwittrock Two things...

  1. How do I specify a custom data type such as email? What's the right annotation? https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#data-types
  2. What's the right annotation to set the pattern?

@pwittrock
Copy link
Contributor

@mattfarina

  1. This may not be supported today, but should be possible to add with relatively little work if the CRD validation supports this use case.

  2. Sorry about this. I'll update the godoc documentation to include Pattern and the other supported types. For now this should work. Remember to run kubebuilder generate afterward.

// +kubebuilder:validation:Pattern=^[a-z]+$

@pwittrock
Copy link
Contributor

pwittrock commented Apr 10, 2018

@mattfarina Filed #67 to support annotating fields with the format generated for openapi.

@mattfarina
Copy link
Author

@pwittrock Thanks. You can consider my question answered. I'll leave this open in case you want to keep it open until you've updated the godocs. Or, you can close it if not.

@pwittrock pwittrock changed the title How do I express uri and email forms of validation? Define how to express uri and email forms (Renamed) May 11, 2018
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

No branches or pull requests

3 participants