Paqmind / react-ultimate

React Ultimate Example
MIT License
303 stars 64 forks source link

Rethink architecture concepts #78

Closed ivan-kleshnin closed 9 years ago

ivan-kleshnin commented 9 years ago

Current concepts

type

Independent.

JS types

validator

Depends on type.

  1. Converts input types
  2. Provides validation errors

    model

Depends on validator.

  1. Converts input types (with validator)
  2. Raises an error for invalid input
  3. Generate defaults for some optional input

This violates the Single Responsibility principle.

maker

Depends on model.

  1. Generates values for required model input

    Proposed concepts

    type

Independent.

JS types (Tcomb types) + Custom types

  1. Raises an error for invalid input

    parser

Independent.

  1. Converts input types (with Globalize)

    maker

Depends on model.

  1. Generates values for all inputs
ivan-kleshnin commented 9 years ago

Consequences:

  1. Remove JOI dependency.
  2. Add TComb and Globalize dependency.
  3. Remove model concept. Roughly replaced with types. E.g. User will be a Tcomb type.
  4. Remove generate value for optional input behavior.
  5. Add parse & format concept independent of validation.
scabbiaza commented 9 years ago

:+1:

ivan-kleshnin commented 9 years ago

Implemented.