/
dedaMazai
/
TestServer
Обзор
Документация
Войти
/
dedaMazai
/
TestServer
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/features/editableProfileCard/model/services/validateProfileData/validateProfileData.ts
26 строк
662 B
Andrey Chipizubov
fix
23 апр 2023, 17:32
23 апр 2023, 17:32
cc424e9
Код
Авторство
О чём код?
import { Profile } from '@/entities/Profile'; import { ValidateProfileError } from '../../consts/consts'; export const validateProfileData = (profile?: Profile) => { if (!profile) { return [ValidateProfileError.NO_DATA]; } const { first, lastname, age, country } = profile; const errors: ValidateProfileError[] = []; if (!first || !lastname) { errors.push(ValidateProfileError.INCORRECT_USER_DATA); } if (!age || !Number.isInteger(age)) { errors.push(ValidateProfileError.INCORRECT_AGE); } if (!country) { errors.push(ValidateProfileError.INCORRECT_COUNTRY); } return errors; };