export const TITLE_MIN = 3 export const TITLE_MAX = 200 export const TITLE_SERVER_MESSAGE = 'Article title must be between 3 and 200 characters.' export type TitleVerdict = 'ok' | 'empty' | 'short' | 'long' export function titleLength(title: string) { return Array.from(title).length } export function titleVerdict(title: string): TitleVerdict { const length = titleLength(title) if (length === 0) { return 'empty' } if (length < TITLE_MIN) { return 'short' } return length > TITLE_MAX ? 'long' : 'ok' }