diff --git a/src/libs/ui/forms/form-validation-rules.ts b/src/libs/ui/forms/form-validation-rules.ts index cb19c0e27..ed1f33c9c 100644 --- a/src/libs/ui/forms/form-validation-rules.ts +++ b/src/libs/ui/forms/form-validation-rules.ts @@ -369,7 +369,10 @@ export const useCSPRStakeAmountRule = ( }); }; -export const useValidatorPublicKeyRule = (delegatorsNumber?: number) => { +export const useValidatorPublicKeyRule = ( + stakesType: AuctionManagerEntryPoint, + delegatorsNumber?: number +) => { const { t } = useTranslation(); return Yup.string() @@ -381,7 +384,16 @@ export const useValidatorPublicKeyRule = (delegatorsNumber?: number) => { }) .test({ name: 'maxDelegators', - test: () => !(delegatorsNumber && delegatorsNumber >= MAX_DELEGATORS), + test: () => { + if (stakesType === AuctionManagerEntryPoint.undelegate) { + return true; + } + if (delegatorsNumber) { + return delegatorsNumber < MAX_DELEGATORS; + } + + return false; + }, message: t( 'This validator has reached the network limit for total delegators and therefore cannot be delegated to by new accounts. Please select another validator with fewer than 1200 total delegators' ) diff --git a/src/libs/ui/forms/stakes-form.ts b/src/libs/ui/forms/stakes-form.ts index 5a96a6ab7..f066e39b9 100644 --- a/src/libs/ui/forms/stakes-form.ts +++ b/src/libs/ui/forms/stakes-form.ts @@ -24,7 +24,7 @@ export const useStakesForm = ( delegatorsNumber?: number ) => { const validatorFormSchema = Yup.object().shape({ - validatorPublicKey: useValidatorPublicKeyRule(delegatorsNumber) + validatorPublicKey: useValidatorPublicKeyRule(stakesType, delegatorsNumber) }); const validatorFormOptions: UseFormProps = {