mirror of
https://github.com/Nezumi-2711/react-training.git
synced 2026-09-22 20:01:59 +00:00
Update README and LoginForm
This commit is contained in:
@@ -56,7 +56,8 @@ const REGEX = {
|
||||
PHONE: /(0[3|5|7|8|9])+([0-9]{8})\b/g,
|
||||
NAME: /^[a-zA-Z]{2,}(?: [a-zA-Z]+){0,2}$/gm,
|
||||
NUMBER: /^[0-9]*$/,
|
||||
PASSWORD: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[#$@!%&*?])[A-Za-z\d#$@!%&*?]{8,16}$/
|
||||
PASSWORD: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[#$@!%&*?])[A-Za-z\d#$@!%&*?]{8,16}$/,
|
||||
EMAIL: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,
|
||||
};
|
||||
|
||||
export {
|
||||
|
||||
@@ -7,6 +7,7 @@ const PASSWORD_CONDITION =
|
||||
const INVALID_PASSWORD = 'Invalid password';
|
||||
const PASSWORD_NOT_MATCH = 'Password not match!';
|
||||
const PASSWORD_NOT_MATCH_REQUIREMENT = 'Password not match the requirement!';
|
||||
const INVALID_EMAIL = 'Invalid email address';
|
||||
|
||||
export {
|
||||
REQUIRED_FIELD_ERROR,
|
||||
@@ -17,4 +18,5 @@ export {
|
||||
INVALID_PASSWORD,
|
||||
PASSWORD_NOT_MATCH,
|
||||
PASSWORD_NOT_MATCH_REQUIREMENT,
|
||||
INVALID_EMAIL,
|
||||
};
|
||||
|
||||
@@ -8,7 +8,10 @@ import { FieldInput, StyledLoginForm } from './styled';
|
||||
import Button from '@commonStyle/Button';
|
||||
|
||||
// Constants
|
||||
import { REQUIRED_FIELD_ERROR } from '@constant/formValidateMessage';
|
||||
import {
|
||||
INVALID_EMAIL,
|
||||
REQUIRED_FIELD_ERROR,
|
||||
} from '@constant/formValidateMessage';
|
||||
|
||||
// Types
|
||||
import { ILogin } from '@type/common';
|
||||
@@ -16,6 +19,12 @@ import { ILogin } from '@type/common';
|
||||
// Hooks
|
||||
import { useLogin } from '@hook/authentication/useLogin';
|
||||
|
||||
// Helpers
|
||||
import { isValidRegex } from '@helper/validators';
|
||||
|
||||
// Constants
|
||||
import { REGEX } from '@constant/commons';
|
||||
|
||||
const LoginForm = () => {
|
||||
const {
|
||||
register,
|
||||
@@ -41,10 +50,8 @@ const LoginForm = () => {
|
||||
id="email"
|
||||
{...register('email', {
|
||||
required: REQUIRED_FIELD_ERROR,
|
||||
pattern: {
|
||||
value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,
|
||||
message: 'Invalid email address',
|
||||
},
|
||||
validate: (value) =>
|
||||
isValidRegex(REGEX.EMAIL, value) || INVALID_EMAIL,
|
||||
})}
|
||||
/>
|
||||
</Form.Row>
|
||||
|
||||
Reference in New Issue
Block a user