Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix state properties cross reducer collision #1

Open
paradigm314 opened this issue Dec 6, 2017 · 2 comments
Open

Fix state properties cross reducer collision #1

paradigm314 opened this issue Dec 6, 2017 · 2 comments

Comments

@paradigm314
Copy link
Collaborator

Currently validstate combines reducers together into unified state to run validations. This will cause a collision if properties are named the name across multiple reducers such as:

  • auth.email and contact.email

To resolve validstate_config should respect reducer namespaces and property keys should allow dot notation for access. IE

account: {
    'auth.name': { required: true },
    'auth.email': { email: true },
    'auth.password': { minLength: 8 },
  }

where auth is the key of the reducer inside of the combineReducers method.

@paradigm314 paradigm314 added this to the 1.1.0 milestone Dec 6, 2017
@paradigm314
Copy link
Collaborator Author

In addition, to make syntax simple for single reducer validations a _reducer option should be added to define one reducer source. IE

account: {
    _reducer:  'auth',
    'name': { required: true },
    'email': { email: true },
    'password': { minLength: 8 },
  }

@paradigm314
Copy link
Collaborator Author

After talking through the implementation of this we have decided that it would be best to keep the interface consistent so the API will use _ values for reducer in the properties instead of dot notation like so:

account: {
    _reducer:  'auth',
    'name': { required: true },
    'email': { email: true },
    'password': { minLength: 8 },
    'paymentMethod: { required: true, _reducer: 'payments' }
  }

Where the property `_reducer` setting will override the overall validation setting. 
If a validation and property both are missing the `_reducer` key than a `ConfigurationError` should be thrown. 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant