Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Formik and Yup is a lovley combination. It just works, and it does what it does really well. But just like any combination of two different frameworks, sometimes you need some help. And that is why I've created this package, containing a few but important helpers for make sure the glue between Formik and Yup is as strong as it possibly can be.
When Formik is performing its validation only errors will be returned and managed. Any transforms applied by Yup will therefore not be updating the Formik form values. So, using any transform methods from Yup with Formik will not have any implications on the final submit model. Here are my Yup transform helpers, that will do its best to apply any Yup transforms, and warn for any failed transforms that could not be applied by this package.
Note that any helper functions are async and will return a
Promise
.
input:
value: Value, form: FormikHelpers<any>, validationSchema: Schema, fieldName: string
> return: formatted valuePromise<formattedValue: Value>
Value transform helper for a single field. Useful for applying transforms on, for example, blur
or click
events. This will modify the value internally, so no manual actions needs to be taken to make sure the form is up to date with the transforms.
Example usage (within a Formik field render):
<TextField
{...field}
onBlur={e => {
formikFieldApplyYupTransforms(
field.value,
form,
validationSchema,
field.name
);
form.handleBlur(e);
}}
/>
input:
values: Payload, form: FormikHelpers<Payload>, validationSchema: Schema
> return array of the formatted values and an hasErrors boolean:Promise<[formattedValues, hasErrors]>
Value transform helper for a the whole form. Useful for applying transforms on Formik submit
. This will modify the value internally, so no manual actions needs to be taken to make sure the form is up to date with the transforms.
Example usage:
const onSubmit = async (
values: Payload,
form: FormikActions<Payload>
) => {
const [formattedValues, hasErrors] = await formikFormApplyYupTransforms(
values,
form,
validationSchema
);
if (hasErrors) {
return;
}
onSubmit(formattedValues);
};
FAQs
Helpers for Formik with Yup validation
The npm package formik-yup receives a total of 367 weekly downloads. As such, formik-yup popularity was classified as not popular.
We found that formik-yup 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’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.