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.
js-mui-formik
Advanced tools
material ui mui formik mask
import { useFormik } from 'formik';
import { FormikMuiTextField} from 'js-mui-formik'
import { useState } from 'react';
import * as yup from 'yup';
export default function App() {
const validationSchema = yup.object({
name: yup.string().required('Please enter name').min(2, "Name too short")
});
const [name, setName] = useState<string>("");
const formik = useFormik({
initialValues: {name},
enableReinitialize: true,
validationSchema: validationSchema,
onSubmit: (values, formikHelpers) => {
setName(() => values.name);
formikHelpers.resetForm();
},
});
return (
<div>
<h1>Hello {name} </h1>
<form onSubmit={formik.handleSubmit}>
<FormikMuiTextField name="name" label="Name" formik={formik}/>
<button type="submit">Submit</button>
</form>
</div>
)
}
import { useFormik } from 'formik';
import { FormikMuiMaskedTextField, FormikMuiTextField } from 'js-mui-formik'
import { BR_MOBILE_MASK, BR_PHONE_MASK } from 'js-mui-formik'
import { useState } from 'react';
import styled from 'styled-components';
import * as yup from 'yup';
const InputWrapper = styled.div`margin: 1rem 0`;
class User {
name: string;
phone: string;
mobile: string;
constructor() {
this.name = "";
this.phone = "";
this.mobile = "";
}
}
export default function ShowInputs() {
const validationSchema = yup.object({
name: yup.string().required('Please enter name').min(2, "Name too short"),
phone: yup.string().required('Please enter phone').min(11, "Phone too short"),
mobile: yup.string().required('Please enter mobile').min(12, "Phone too short")
});
const [user, setUser] = useState<User>(new User);
const formik = useFormik({
initialValues: { ...user },
enableReinitialize: true,
validationSchema: validationSchema,
validateOnMount: true,
onSubmit: (values, formikHelpers) => {
setUser(() => values);
formikHelpers.resetForm();
},
});
return (
<div>
<h1>
Hello {user?.name ? user?.name : '______'},
your phone is {user?.phone ? user?.phone : '_____'}
and your mobile is {user?.mobile ? user?.mobile : '_____'}.
</h1>
<form onSubmit={formik.handleSubmit}>
<InputWrapper>
<FormikMuiTextField
name="name"
label="Name"
placeholder='Enter with your name'
formik={formik} />
</InputWrapper>
<InputWrapper>
<FormikMuiMaskedTextField
id="phone"
name="phone"
mask={BR_PHONE_MASK}
alternativeMask={BR_MOBILE_MASK}
testAlternativeMask={(value: string) => value.replace(/\D/g, '')[2] === '9'}
label="Phone"
formik={formik} />
</InputWrapper>
<InputWrapper>
<FormikMuiMaskedTextField
id="mobile"
name="mobile"
mask={BR_MOBILE_MASK}
label="Mobile"
formik={formik} />
</InputWrapper>
<button type="submit">Submit</button>
</form>
</div>
)
}
BR_PHONE_MASK = ['(', /\d/, /\d/, ')', ' ', /\d/, /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/]; BR_MOBILE_MASK= ['(', /\d/, /\d/, ')', ' ', /\d/, /\d/, /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/]; BR_CEP_MASK = [/[\d]/, /\d/,'.', /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/]; BR_CNPJ_MASK = [/\d/, /\d/, '.', /\d/, /\d/, /\d/, '.', /\d/, /\d/, /\d/,'/', /\d/, /\d/, /\d/, /\d/, '-', /\d/, /\d/]; BR_CPF_MASK = [/\d/, /\d/, /\d/,'.', /\d/, /\d/, /\d/, '.', /\d/, /\d/, /\d/,'-', /\d/, /\d/]; TEST_BR_MOBILE_MASK = (value: string) => value.replace(/\D/g, '')[2] === '9'
FAQs
TextFields Material UI with Formik and masks
The npm package js-mui-formik receives a total of 23 weekly downloads. As such, js-mui-formik popularity was classified as not popular.
We found that js-mui-formik 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.