-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(xod-client): util to check React props with sanctuary def
without `env`(see sanctuary-js/sanctuary-def#123), but good enough for now.
- Loading branch information
1 parent
e4635e9
commit 58ee35e
Showing
3 changed files
with
15 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import $ from 'sanctuary-def'; | ||
|
||
// only returning if the validation fails is an accepted pattern | ||
// eslint-disable-next-line consistent-return | ||
export default Type => (props, propName, componentName) => { | ||
const env = []; // TODO | ||
|
||
if (!$.test(env, Type, props[propName])) { | ||
return new Error(`Invalid prop '${propName}' supplied to '${componentName}'`); | ||
} | ||
}; |