Git Product home page Git Product logo

Comments (5)

adriangb avatar adriangb commented on May 18, 2024 2

I would also lean towards one single syntax: I imagine these schemas are (mostly) going to be programmatically generated, so having shorthand is only really helpful for writing tests for this package.

from pydantic-core.

samuelcolvin avatar samuelcolvin commented on May 18, 2024 1

From #92 (review)

We want an intermediate dict above schema on a field. This does not affect the rust validators or validation, just the python interface for building schema.

Example:

{
    'type': 'model',
    'fields': {
        'field_a': {
            'required': True,
            'schema': {'type': 'str'},
        },
        'field_b': {
            'default': 123,
            'alias': ...
            'schema': {'type': 'int'},
        },
    }
}

We might add other stuff beyond required, schema, alias.

from pydantic-core.

PrettyWood avatar PrettyWood commented on May 18, 2024

@samuelcolvin I see 'fields': {'age': 'int'} as a shortcut for 'fields': {'age': {'type': 'int'}}, do you want to keep this?
If yes do you expect 'fields': {'age': {'type': 'int'}} to be a shortcut for 'fields': {'age': {'schema': {'type': 'int'}}} if no default, alias, ... is set?
Personally I like to have only one syntax even if nothing else is set (i.e. no shortcut) but it's your call ;)

from pydantic-core.

samuelcolvin avatar samuelcolvin commented on May 18, 2024

Completely up to you, whatever you think is best.

Having a single schema will make it simpler and in particular, make the python type hints easier.

We already allow 'int' is equivalent to {'type': 'int'}, so you may as well leave that bit as-is.

from pydantic-core.

PrettyWood avatar PrettyWood commented on May 18, 2024

Yep my thoughts exactly! I just opened #97

from pydantic-core.

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.