refactor: enforce semantic values and numeric lint rules
This commit is contained in:
@@ -1,11 +1,17 @@
|
||||
import { z } from "zod";
|
||||
import { validationMessage } from "@/shared/i18n";
|
||||
|
||||
const ASCII_SPACE = 32;
|
||||
const ASCII_DELETE = 127;
|
||||
const MAX_EMAIL_LENGTH = 254;
|
||||
const MIN_PASSWORD_BYTES = 12;
|
||||
const MAX_PASSWORD_BYTES = 72;
|
||||
|
||||
function isEmailCharacterInvalid(character: string): boolean {
|
||||
return (
|
||||
/\s/.test(character) ||
|
||||
character.charCodeAt(0) < 32 ||
|
||||
character.charCodeAt(0) === 127
|
||||
character.charCodeAt(0) < ASCII_SPACE ||
|
||||
character.charCodeAt(0) === ASCII_DELETE
|
||||
);
|
||||
}
|
||||
|
||||
@@ -13,7 +19,7 @@ const email = z
|
||||
.string()
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.max(254)
|
||||
.max(MAX_EMAIL_LENGTH)
|
||||
.refine(
|
||||
(value) =>
|
||||
value.split("@").length === 2 &&
|
||||
@@ -25,8 +31,8 @@ const password = z
|
||||
.string()
|
||||
.refine(
|
||||
(value) =>
|
||||
new TextEncoder().encode(value).length >= 12 &&
|
||||
new TextEncoder().encode(value).length <= 72,
|
||||
new TextEncoder().encode(value).length >= MIN_PASSWORD_BYTES &&
|
||||
new TextEncoder().encode(value).length <= MAX_PASSWORD_BYTES,
|
||||
validationMessage("auth.validation.invalidPasswordLength"),
|
||||
);
|
||||
|
||||
|
||||
@@ -14,6 +14,9 @@ import { LoadingSkeleton } from "@/shared/ui";
|
||||
import type { SectionState } from "../model/section";
|
||||
import classes from "./InstrumentDetails.module.css";
|
||||
|
||||
const CHART_SKELETON_HEIGHT_PX = 280;
|
||||
const SECTION_SKELETON_HEIGHT_PX = 65;
|
||||
|
||||
type InstrumentSectionProps = PropsWithChildren<{
|
||||
title: string;
|
||||
state: SectionState;
|
||||
@@ -59,7 +62,13 @@ const InstrumentSection: FC<InstrumentSectionProps> = (props) => {
|
||||
label={t("stock.loadingSection", { section: props.title })}
|
||||
>
|
||||
<Stack>
|
||||
<Skeleton h={props.large ? 280 : 65} />
|
||||
<Skeleton
|
||||
h={
|
||||
props.large
|
||||
? CHART_SKELETON_HEIGHT_PX
|
||||
: SECTION_SKELETON_HEIGHT_PX
|
||||
}
|
||||
/>
|
||||
<Skeleton h={14} w="60%" />
|
||||
</Stack>
|
||||
</LoadingSkeleton>
|
||||
|
||||
Reference in New Issue
Block a user