react-action-validation
Advanced tools
Comparing version 0.0.10-alpha to 0.0.11-alpha
14
index.js
@@ -91,3 +91,3 @@ import Joi from '@hapi/joi'; | ||
var validationGate = (function (validations) { | ||
return function () { | ||
return function (store) { | ||
return function (next) { | ||
@@ -117,3 +117,3 @@ return /*#__PURE__*/function () { | ||
case 8: | ||
validation.accept(action.type); | ||
validation.accept(store)(action); | ||
next(action); | ||
@@ -127,3 +127,3 @@ _context.next = 16; | ||
console.error(_context.t0); | ||
validation.reject(action.type); | ||
validation.reject(store)(action); | ||
@@ -196,9 +196,9 @@ case 16: | ||
key: "accept", | ||
value: function accept(type) { | ||
console.log("".concat(type, " accepted!")); | ||
value: function accept(store, action) { | ||
console.log("".concat(action.type, " accepted!")); | ||
} | ||
}, { | ||
key: "reject", | ||
value: function reject(type) { | ||
console.error("".concat(type, " rejected!")); | ||
value: function reject(store, action) { | ||
console.error("".concat(action.type, " rejected!")); | ||
} | ||
@@ -205,0 +205,0 @@ }]); |
@@ -1,1 +0,1 @@ | ||
{"name":"react-action-validation","version":"0.0.10-alpha","description":"validates the payload of the dispatched action","main":"./index.js","repository":{"type":"git","url":"git+https://github.com/rezaerami/react-payload-validation.git"},"keywords":["react","hapi","joi","redux","validation","redux","validation","react","validation"],"author":"Reza Erami","license":"MIT","bugs":{"url":"https://github.com/rezaerami/react-payload-validation/issues"},"homepage":"https://github.com/rezaerami/react-payload-validation#readme","dependencies":{"@hapi/joi":"^17.1.1"}} | ||
{"name":"react-action-validation","version":"0.0.11-alpha","description":"validates the payload of the dispatched action","main":"./index.js","repository":{"type":"git","url":"git+https://github.com/rezaerami/react-payload-validation.git"},"keywords":["react","hapi","joi","redux","validation","redux","validation","react","validation"],"author":"Reza Erami","license":"MIT","bugs":{"url":"https://github.com/rezaerami/react-payload-validation/issues"},"homepage":"https://github.com/rezaerami/react-payload-validation#readme","dependencies":{"@hapi/joi":"^17.1.1"}} |
@@ -37,4 +37,2 @@ # react-payload-validation | ||
import authTypes from 'path/to/auth/types'; // path to the files that you wrote your action types | ||
class LoginRequestValidation extends Validator { | ||
@@ -45,5 +43,21 @@ rules = { | ||
}; | ||
accept(store, action){ | ||
console.log(`${action.type} accepted!`); | ||
store.dispatch({ | ||
type: 'LOGIN_ACCEPTED', | ||
payload: 'credentials are valid', | ||
}); | ||
} | ||
reject(store, action){ | ||
console.log(`${action.type} rejected!`); | ||
store.dispatch({ | ||
type: 'LOGIN_REJECTED', | ||
payload: 'credentials are invalid', | ||
}); | ||
} | ||
} | ||
export default assign(authTypes.LOGIN)(LoginRequestValidation); | ||
export default assign('LOGIN_REQUEST')(LoginRequestValidation); | ||
@@ -54,3 +68,3 @@ ``` | ||
```javascript | ||
export default assign([FOO_TYPE, BAR_TYPE])(CustomValidation); | ||
export default assign(['FOO_TYPE', 'BAR_TYPE'])(CustomValidation); | ||
``` | ||
@@ -57,0 +71,0 @@ |
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
9988
163
1