Skip to content

Instantly share code, notes, and snippets.

View NjohPrince's full-sized avatar
Building Start-ups

Njoh Noh Prince Junior NjohPrince

Building Start-ups
View GitHub Profile
@NjohPrince
NjohPrince / update-about-info.validations.ts
Last active May 19, 2024 11:58
This snippet defines custom validation rules for updating user profile information, ensuring that inputs meet specific criteria before form submission. The updateAboutInfoValidations object is designed to validate fields such as about, companyLocation, jobTitle, and company.
import { UpdateAboutInfoType } from '../../../../services/api/profile.service'
import { Place } from '../../../../types'
import { Validations } from '../../../hooks/use-form'
export const updateAboutInfoValidations: Validations<UpdateAboutInfoType> = {
about: {
custom: {
isValid: (value: string) => value?.length >= 128 && value?.length <= 256,
message: 'Your bio should be atleast 128 characters and atmost 256 characters.',
},
@NjohPrince
NjohPrince / use-form.ts
Last active May 24, 2024 03:30
The UseForm hook is a versatile solution for managing form state, validation, and submission in React applications. It simplifies handling forms by providing a clean and efficient way to manage input data, validate fields, and handle form submissions.
import _ from 'lodash'
import { FormEvent, useEffect, useState } from 'react'
import { useAppDispatch } from '.'
import {
NotificationTitleType,
showNotification,
} from '../../app/features/notification/notification.slice'
import { Place } from '../../types'