Skip to content

Consider consolidating everything under a single module. #1

@hayleigh-dot-dev

Description

@hayleigh-dot-dev

Hey this library is a great idea, excited to see someone tackle it! I was checking this out for a project I'm starting and I wanted to suggest some minor change to the api based on existing Gleam idioms/practices.

Typically we consider types modules (aka modules that only contain type definitions) bad practice, and prefer to keep types close to the functions relevant to them. This makes use simpler (I don't have to pull in two modules any time I want to work with json schemas) and makes reference easier (I don't have to jump between two pages to understand the docs).

I'd like to suggest grouping everything under jscheam/schema such that you would do:

import jscheam/schema

let user_schema: schema.Type = schema.object([
  schema.property("name", schema.string()),
  schema.property("age", schema.integer()),
  schema.property("email", schema.string())
])

This establishes a namespace for your package (jscheam) while keeping the api meaningful at the point of use by putting things in a schema module. This pattern is followed by packages like youid where you see youid/uuid.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions