Giter Site home page Giter Site logo

yamamotok / dataobject Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 1.0 627 KB

Decorator-based utility for transformation (serialization/deserialization) between plain object and class instance, developed for TypeScript projects. An alternative to class-validator and class-transformer.

Home Page: https://www.npmjs.com/package/@yamamotok/dataobject

License: MIT License

JavaScript 2.39% TypeScript 97.61%
custom-transformation dataobject deserialization json marshaller npm-package serialization transformation transformer typescript

dataobject's People

Contributors

dependabot[bot] avatar yamamotok avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

muserlink

dataobject's Issues

Validator should be applied in process of transformation

Currently validation is applied before transformation, however I think it should be applied in process of transformation.

  • undefined should be ignored and no need to apply validation (currently validation is before undefined check)
  • It should be after custom transformer because usually a custom transformer has its own validation and type conversion.

Type coercion before validation for primitive types

While "dataobject" has implicit type coercion for primitive types (string, number, and boolean), a validator function to be set looks like this.

(value: unknown) => isLength(String(value), { max: 100 })

I think it would be nice if the type coerced value is passed to validation function.

(value: string) => isLength(value, { max: 100 })

v1.1.0

v1.1.0 will be released in a couple of weeks.

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.