jurassix / react-validation-mixin

Simple validation mixin (HoC) for React.
MIT License
283 stars 38 forks source link

Compound keys (flat style) #13

Closed ivan-kleshnin closed 9 years ago

ivan-kleshnin commented 9 years ago

With compound keys like model.username resulting validation messages may be represented in two styles:

{
  model: {username: []} // nested style (closed PR #12)
}

{
  model.username: [] // flat style (current PR #13)
}

Previous attempt at (https://github.com/jurassix/react-validation-mixin/pull/12) is working but implementation is really complex. All lens libraries I analized are borked. To not create another one, I decided to abandon previous approach and implemented new one where errors object is kept flat. It turned out to be much cleaner.

Now code & tests are ready for review :)

jurassix commented 9 years ago

Great. Will be a nice enhancement. I'm about to cut a 4.0.0 major release of this library. I'll get this PR merged up to master and go over the changes. I'm excited about this one!

ntdb commented 9 years ago

Any updates on this? I'm trying to use the mixin to validate one object in my state with several of its own properties.

jurassix commented 9 years ago

@ntdb I need to revisit this. I think there may be a simpler way to handle this validation case, but need to prototype it before I'm sure. If that doesn't workout I'll begin on moving this into master.

ivan-kleshnin commented 9 years ago

@ntdb mixins are no longer supported, so it's probably worthless to go in that direction too far. You have two ways: 1) make Form component and extend it 2) implement some helper-like toolkit of functions an use them manually

jurassix commented 9 years ago
jurassix commented 9 years ago

Branches have diverged to use this PR. I will be adding support for deep nested object validation in the near future. See #25 for an interim solution.