Code Monkey home page Code Monkey logo

Comments (4)

ahmetb avatar ahmetb commented on July 17, 2024

@aznashwan thanks for the suggestion. My question is what do you mean for "validation"? (e.g. is it a check for required parameters, input format of certain fields etc?)

from azure-sdk-for-go.

aznashwan avatar aznashwan commented on July 17, 2024

Most prevalent example are all the string configuration options scattered around the various resources.
By validation; I mean a way to be ensure that the inputs are valid (prefferably even without making API calls at all).
ex:

func isValidProtocol(protocol string) bool {
     validProtocols := map[string]bool {
         "TCP": true,
         "UDP": true,
         "*": true,
     }
    return validProtocols[protocol] 
}

This can be applied further to a bunch of of other things (ex: given hosted service name contains disallowed characters, given disk size is preposterous etc...)

from azure-sdk-for-go.

ahmetb avatar ahmetb commented on July 17, 2024

@aznashwan unfortunately we consciously removed those checks from the client and we don't want to have those. Here are the reasons:

  1. We think client library should be dumb enough and not be aware of the server's logic.
  2. Adding validation to the client “duplicates” the functionality. (e.g. in both cases, we return an error anyway)
  3. Having such logic at the client makes it possible to easily go “out of sync” (e.g. max chars for hosted service name can be increased on the API but client would require update to support it).

We try to don't do such validations in our hand-written SDKs (because they're hard to maintain and rarely add value). For the new Azure Resource Management SDKs (that will be code-generated), we may do this if the valid input(s)/formats are part of the model spec.

from azure-sdk-for-go.

aznashwan avatar aznashwan commented on July 17, 2024

All very fair points indeed; some of them having crossed my mind as well.

from azure-sdk-for-go.

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.