I create beautiful and robust user interfaces.
gchumillas / schema-fixer Goto Github PK
View Code? Open in Web Editor NEWA node library to "repair" data from external sources
License: ISC License
A node library to "repair" data from external sources
License: ISC License
I create beautiful and robust user interfaces.
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]
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.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.