gcanti / tcomb-form

Forms library for react
https://gcanti.github.io/tcomb-form
MIT License
1.16k stars 136 forks source link

use a getTcombFormFactory(options) static function defined on types in order to retrieve the proper factory #257

Closed gcanti closed 8 years ago

gcanti commented 8 years ago

Example

// instead of
const Country = t.enums.of(['IT', 'US'], 'Country');

const Type = t.struct({
  country: Country
});

const options = {
  fields: {
    country: {
      factory: t.form.Radio
    }
  }
};

// you can write
const Country = t.enums.of(['IT', 'US'], 'Country');

Country.getTcombFormFactory = function (/*options*/) {
  return t.form.Radio;
};

const Type = t.struct({
  country: Country
});

const options = {};
gcanti commented 8 years ago

Released in v0.7.7