Giter VIP home page Giter VIP logo

schema-fixer's Introduction

I create beautiful and robust user interfaces.

schema-fixer's People

Contributors

gchumillas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

schema-fixer's Issues

Update type definitions for the `parse` function

Context:

The parse function is returning the errors as any[] type:

// src/index.d.ts
export function parse<T extends Schema>(value: any, schema: T): [Value<T>, errors: any[]]

which provides little information about the errors structure.

Possible Fix:

Update src/index.d.ts and replace any[] with something more descriptive. For example:

// src/index.d.ts
export type Errors = string | { path: string; errors: Errors }[]
// ...
export function parse<T extends Schema>(value: any, schema: T): [Value<T>, errors: Errors]

Add default pipe for dates?

Was playing with the library and got a bit stuck at what to do w/ Date objects.

I tried casting as "string" but it didn't like that, and there wasn't a pipe for "object". I was able to pipe to "number" which seems to call .getTime(), I think.

Not sure if a built-in pipe for Date objects would be generally useful. If it receives a Number value, it could do new Date(value), if it receives a Date value, pass it through as-is, if it receives a String value maybe it does some Date.parse() or something. Possibly defaults to the current date if no date provided.

It's not clear what the attribute "required" is for

The required attribute is confusing. For example:

// always outputs { data: '' }, no matter if required is false or true
console.log({ data: sf.fix(undefined, sf.string()) })
console.log({ data: sf.fix(undefined, sf.string({ required: false })) })
console.log({ data: sf.fix(undefined, sf.string({ required: true })) })

// outputs { data: undefined }
console.log({ data: sf.fix(undefined, sf.string({ required: false, default: undefined })) })

Should we remove it? After all, the purpose of this library is "fixing" data rather than "evaluating" data.

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.