New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

use-state-validate

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-state-validate - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

2

package.json
{
"name": "use-state-validate",
"version": "1.0.0",
"version": "1.0.1",
"description": "Custom hook to account for state and validation off single state value",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -30,10 +30,20 @@ # use-state-validate

const [`<valueWrapped>`, `<setValue>`, `<cleanValue>`] = useStateValidate(`<initialValue>`, `<rules>`)
const [`<valWrap>`, `<setVal>`, `<cleanVal>`] = useStateValidate(`<initVal>`, `<rules>`)
### Code
``` js
import useStateValidate from "use-state-validate";
const [nameV, setName, cleanName] = useStateValidate("Tim", { required: true
message: {
required: "A name is required"
});
```
| | |
| -------------- | ---- |
| `valueWrapped` | An object containing the raw value and validation data, use `<valueWrapped>`.`value` to get the value |
| `setValue` | Set function, that behaves like `useState`. PLEASE PASS THE RAW VALUE HERE, not a wrapper like object! |
| `cleanValue` | Function to clean the dirty flag. The dirty flag defaults to false, but is set to true if `setValue` is invoked |
| `initialValue` | The initial value to start with |
| `valWrap` | An object containing the raw value and validation data, use `<valWrap>`.`value` to get the value |
| `setVal` | Set function, that behaves like `useState`. PLEASE PASS THE RAW VALUE HERE, not a wrapper like object! |
| `cleanVal` | Function to clean the dirty flag. The dirty flag defaults to false, but is set to true if `setVal` is invoked |
| `initVal` | The initial value to start with |
| `rules` | A mostly flat object using rules found at https://www.npmjs.com/package/validate |

@@ -60,3 +70,3 @@

### Example of `valueWrapped`, showing the validation data object
### Illustration of `valueWrapped`, showing the validation wrapper object
``` json

@@ -110,4 +120,5 @@ {

### Changelog
v0.0.x - Initial dev release - ASSUME UNSTABLE
v0.0.x - Initial dev release - ASSUME UNSTABLE
v1.0.0 - Hook has been stable in projects, bumping to initial release
v1.0.1 - Readme updates - no code changes
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc