Explorar el Código

password & enName & chName & email set length

master
Anna Ho hace 1 año
padre
commit
0c66d7f506
Se han modificado 5 ficheros con 29 adiciones y 8 borrados
  1. +5
    -1
      src/pages/_Test/Mail/index.js
  2. +7
    -0
      src/pages/authentication/ForgotUsername/AuthCallback/index.js
  3. +7
    -2
      src/pages/authentication/auth-forms/AuthLogin.js
  4. +9
    -4
      src/pages/authentication/auth-forms/AuthRegister.js
  5. +1
    -1
      src/pages/authentication/auth-forms/BusCustomFormWizard.js

+ 5
- 1
src/pages/_Test/Mail/index.js Ver fichero

@@ -24,11 +24,15 @@ const Mail = () => {
const [isResponsPopUp, setIsResponsPopUp] = React.useState(false);
const [responsText, setResponsText] = React.useState("");

function getMaxErrStr(num, fieldname){
return intl.formatMessage({ id: 'noMoreThenNWords' },{num:num, fieldname:fieldname?intl.formatMessage({ id: fieldname})+": ":""});
}

const formik = useFormik({
enableReinitialize:true,
initialValues:{email:""},
validationSchema:yup.object().shape({
email: yup.string().max(255).required(intl.formatMessage({id: 'require'}) + 'e-Mail')
email: yup.string().max(128, getMaxErrStr(128)).required(intl.formatMessage({id: 'require'}) + 'e-Mail')
}),
onSubmit:values=>{
console.log(values);


+ 7
- 0
src/pages/authentication/ForgotUsername/AuthCallback/index.js Ver fichero

@@ -158,6 +158,11 @@ const Index = () => {
// setLevel(strengthColorChi(temp));
};

function getMaxErrStr(num, fieldname){
return intl.formatMessage({ id: 'noMoreThenNWords' },{num:num, fieldname:fieldname?intl.formatMessage({ id: fieldname})+": ":""});
}

const formik = useFormik({
enableReinitialize: true,
initialValues: {
@@ -170,6 +175,7 @@ const Index = () => {
// emailVerifyHash: yup.string().required(intl.formatMessage({id: 'requireSecurityCode'})),
// username: yup.string().required(intl.formatMessage({id: 'requireUsername'})),
password: yup.string().min(8, intl.formatMessage({id: 'atLeast8CharPassword'}))
.max(60, getMaxErrStr(60))
.required(intl.formatMessage({id: 'requirePassword'}))
.matches(/^\S*$/, { message: (intl.formatMessage({id: 'noSpacePassword'}))})
.matches(/^(?=.*[a-z])/, { message: intl.formatMessage({id: 'atLeastOneSmallLetter'})})
@@ -177,6 +183,7 @@ const Index = () => {
.matches(/^(?=.*[0-9])/, { message: intl.formatMessage({id: 'atLeast1Number'})})
.matches(/^(?=.*[!@#%&])/, { message: intl.formatMessage({id: 'atLeast1SpecialChar'})}),
confirmPassword: yup.string().min(8, intl.formatMessage({id: 'atLeast8CharPassword'}))
.max(60, getMaxErrStr(60))
.required(intl.formatMessage({id: 'pleaseConfirmPassword'}))
.oneOf([yup.ref('password'), null], intl.formatMessage({id: 'samePassword'})),
}),


+ 7
- 2
src/pages/authentication/auth-forms/AuthLogin.js Ver fichero

@@ -103,6 +103,11 @@ const AuthLogin = () => {
const onPasswordChange = (event) => {
setUserPassword(event.target.value);
}

function getMaxErrStr(num, fieldname){
return intl.formatMessage({ id: 'noMoreThenNWords' },{num:num, fieldname:fieldname?intl.formatMessage({ id: fieldname})+": ":""});
}

return (
<>
<Formik
@@ -112,8 +117,8 @@ const AuthLogin = () => {
submit: null
}}
validationSchema={Yup.object().shape({
email: Yup.string().email('Must be a valid email').max(255).required('Email is required'),
password: Yup.string().max(255).required('Password is required')
email: Yup.string().max(128,getMaxErrStr(128)).email('Must be a valid email').required('Email is required'),
password: Yup.string().max(60, getMaxErrStr(60)).required('Password is required')
})}
onSubmit={async (values, { setErrors, setStatus, setSubmitting }) => {
try {


+ 9
- 4
src/pages/authentication/auth-forms/AuthRegister.js Ver fichero

@@ -52,6 +52,11 @@ const AuthRegister = () => {
changePassword('');
}, []);

function getMaxErrStr(num, fieldname){
return intl.formatMessage({ id: 'noMoreThenNWords' },{num:num, fieldname:fieldname?intl.formatMessage({ id: fieldname})+": ":""});
}


return (
<>
<Formik
@@ -64,10 +69,10 @@ const AuthRegister = () => {
submit: null
}}
validationSchema={Yup.object().shape({
firstname: Yup.string().max(255).required('First Name is required'),
lastname: Yup.string().max(255).required('Last Name is required'),
email: Yup.string().email('Must be a valid email').max(255).required('Email is required'),
password: Yup.string().max(255).required('Password is required')
firstname: Yup.string().max(30, getMaxErrStr(30)).required('First Name is required'),
lastname: Yup.string().max(30, getMaxErrStr(30)).required('Last Name is required'),
email: Yup.string().email('Must be a valid email').max(128, getMaxErrStr(128)).required('Email is required'),
password: Yup.string().max(60, getMaxErrStr(60)).required('Password is required')
})}
onSubmit={async (values, { setErrors, setStatus, setSubmitting }) => {
try {


+ 1
- 1
src/pages/authentication/auth-forms/BusCustomFormWizard.js Ver fichero

@@ -537,7 +537,7 @@ const BusCustomFormWizard = (props) => {
address1: yup.string().max(40, getMaxErrStr(40)).required(displayErrorMsg(intl.formatMessage({id: 'validateAddressLine1'}))),
address2: yup.string().max(40, getMaxErrStr(40)),
address3: yup.string().max(40, getMaxErrStr(40)),
email: yup.string().email(displayErrorMsg(intl.formatMessage({id: 'validEmailFormat'}))).max(255, getMaxErrStr(128)).required(displayErrorMsg(intl.formatMessage({id: 'requireEmail'}))),
email: yup.string().email(displayErrorMsg(intl.formatMessage({id: 'validEmailFormat'}))).max(128, getMaxErrStr(128)).required(displayErrorMsg(intl.formatMessage({id: 'requireEmail'}))),
emailConfirm: yup.string().email(displayErrorMsg(intl.formatMessage({id: 'validEmailFormat'}))).max(128, getMaxErrStr(128)).required(displayErrorMsg(intl.formatMessage({id: 'requireEmail'}))).oneOf([yup.ref('email'), null], displayErrorMsg(intl.formatMessage({id: 'validSameEmail'}))),
phoneCountryCode: yup.string().min(2, displayErrorMsg(intl.formatMessage({id: 'requireAtLeast2Number'}))).required(displayErrorMsg(intl.formatMessage({id: 'requireDialingCode'}))),
faxCountryCode: yup.string().min(2, displayErrorMsg(intl.formatMessage({id: 'requireAtLeast2Number'}))),


Cargando…
Cancelar
Guardar