Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.

Incosistent calling of tcomb-validation validate function in getTypeInfo and components for struct and list types #253

Closed
minedeljkovic opened this issue Nov 16, 2015 · 3 comments
Milestone

Comments

@minedeljkovic
Copy link
Contributor

  1. In Struct and List components, t.validate is called with value that is built by their child components (i.e. with values that are results of calling child components validate method).
  2. In getTypeInfo (util module), or more precise in getValidationErrorMessage method that is built, t.validate is called with value that is received from base Component's getError method. That value is built from state with calling top level transformer only.

One of the consequences is that if struct or list item type has properties of types that are parsed by their own transformers (e.g. number type), and valid strings are set for those properties, case 1. will not find validation errors (since those strings are parsed by their components, when their validate method is called), but case 2. will find validation errors (since those strings are not parsed)

@gcanti
Copy link
Owner

gcanti commented Nov 16, 2015

Hi @minedeljkovic !
thanks for pointing out.

Yes it's inconsistent, honestly I'm not that proud of that code, it's the fruit of too many tweaks.

Working on this...

p.s.
it's difficult to find a test case that raises an inconsistent behaviour. Do you have a "failing" test case at hand?

@minedeljkovic
Copy link
Contributor Author

It is not easy to write a proper test in current test suite, since it depends on setState and that requires components to be mounted.
I hacked it heavily and tried to back it up with comments. You can find it here:
https://github.com/minedeljkovic/tcomb-form/blob/master/test/components/Component.js#L165

I am not sure if this is helpful. :(

@gcanti gcanti closed this as completed in e6c4a9b Nov 17, 2015
@gcanti
Copy link
Owner

gcanti commented Nov 17, 2015

Thanks a lot @minedeljkovic, just pushed a fix on master

@gcanti gcanti added this to the v0.7.7 milestone Nov 23, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants