Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
@nvidia1997/react-js-validator
Advanced tools
#### This is react-wrapper for [js-validator](https://www.npmjs.com/package/@nvidia1997/js-validator). #### Please read its docs first!
import {ValidatorProvider, ValidatorContext, ValidatorConsumer, withValidator} from "@nvidia1997/react-js-validator";
<SomeComponent> // not necessary to wrap ValidatorProvider
<ValidatorProvider>// in this case we only need to import ValidatorProvider
<WrappedComponent/>
</ValidatorProvider>
</SomeComponent>
function WrappedComponent(props){
return (
<div>some text</div>
);
}
export default withValidator(WrappedComponent);
import {useValidatorContext} from "@nvidia1997/react-js-validator";
const [text1, setText1] = useState("");
const [text2, setText2] = useState("");
// timestamp variable is needed only if you're using allowNull, allowUndefined, notRequired validations and validation on change at the same time
const [timestamp, setTimestamp] = useState(Date.now());
const {
validator,
createOnFormSubmitHandler,
createOnValidationSuccessHandler
} = useValidatorContext();
useEffect(() => {
validator
.string(text1, "text1Validator")
.notNull()
.notUndefined()
.maxLength(2)
//.validate(false); // uncomment if you want the validations to occur on text change
validator
.string(text2, "text2Validator")
.maxLength(3)
//.validate(); //only last validate method must be without "false" as param. This will fire onStateChanged only once.
return () => {
validator.removeValidator("text1Validator");//remove validators when dismounting components to avoid hidden validation errors
validator.removeValidator("text2Validator");
}
}, [validator, text1, text2, timestamp]);// if we're not doing validation on change, timestamp is not required
const onSubmitSuccess = (e) => {
console.log("form submitted");
};
const onSubmitFailure = (e) => {
console.log("form NOT submitted, validation errors occurred");
};
const onText1Change = (e) => {
setText1(e.target.value);
};
const onText2Change = (e) => {
setText2(e.target.value);
};
<form onSubmit={createOnFormSubmitHandler(onSubmitSuccess, onSubmitFailure)} action="/some_action.php">
<input type="text" value={text1} onChange={onText1Change}/>
<input type="text" value={text2} onChange={onText2Change}/>
<input type="submit" value="Submit"/>
</form>
const onValidationSuccess = (e) => {
console.log("validation successful");
};
const onValidationFailure= (e) => {
console.log("oops, some fields have errors");
};
<button onClick={createOnValidationHandler(onValidationSuccess, onValidationFailure)}>
validate
</button>
<button onClick={() => {validator.reset(); }}>
reset
</button>
<span>{validator.hasErrors.toString()}</span>
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
FAQs
#### This is react-wrapper for [js-validator](https://www.npmjs.com/package/@nvidia1997/js-validator). #### Please read its docs first!
The npm package @nvidia1997/react-js-validator receives a total of 2 weekly downloads. As such, @nvidia1997/react-js-validator popularity was classified as not popular.
We found that @nvidia1997/react-js-validator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.