Skip to content

clarify/schema

Repository files navigation

Schema

This repo holds a proto-type for new schema package for rest-layer.

More info on rs/rest-layer#77

Goals:

Specifically fo references:

  • Allow reference checks to operate with the correct context.
  • Allow [embedding] to rely on an interface.

The proto-type will only focus on the schema parts, not the other rest-layer packages. It will not replicate/include the schmea/query package.

Example schema

TODO: All the definitions and types to construct this example is not yet in place.

package main

import "github.com/searis/schema"

var userSchema = schema.Schema{
    Title: "User",
    Description: "Holds information about a user",
    Type: schema.Object{
        Required: []string{"id", "name"},
        Properties: map[string]schema.Schema{
            "id": schema.Schema{
                Type: schema.XIDField{},
                ReadOnly: true,
            },
            "name": schema.Schema{
                Type: schema.String{
                    MinLen: 1,
                    MaxLen: 255,
                },
            },
            "email": schema.Schema{
                Type: schema.Email(), // A sepcialized initalizer for String.
            },
        },
    },
}

func main() {
    // Compile the interfaces you need.
    parser := userSchema.Parser()
    validator := userSchema.Validator()
    serializer := userSchema.Serializer()

    ...
}

Test format

Most unit tests are written on a GWT format using Go sub-tests.

About

Proto-type for new schema package

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages