Giter Site home page Giter Site logo

Comments (5)

pwittrock avatar pwittrock commented on June 21, 2024

@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".

from kubebuilder.

mattfarina avatar mattfarina commented on June 21, 2024

@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?

from kubebuilder.

pwittrock avatar pwittrock commented on June 21, 2024

@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]+$

from kubebuilder.

pwittrock avatar pwittrock commented on June 21, 2024

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

from kubebuilder.

mattfarina avatar mattfarina commented on June 21, 2024

@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.

from kubebuilder.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.