Skip to content

Commit

Permalink
Ease validation for minContext and maxContext (Joystream#2601)
Browse files Browse the repository at this point in the history
  • Loading branch information
Joystream Stats committed Nov 1, 2022
1 parent 6f249a2 commit 349e163
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/ui/src/common/utils/validation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const maxContext = (
}

const validationValue = new BN(get(this.options.context, contextPath))
if (validationValue && validationValue.lt(new BN(value))) {
if (validationValue && validationValue.lte(new BN(value))) {
return this.createError({
message: msg,
params: {
Expand Down Expand Up @@ -63,7 +63,7 @@ export const minContext = (
}

const validationValue = new BN(get(this.options.context, contextPath))
if (validationValue && validationValue.gt(new BN(value))) {
if (validationValue && validationValue.gte(new BN(value))) {
return this.createError({
message: msg,
params: {
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/proposals/modals/AddNewProposal/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,11 @@ export const schemaFactory = (api?: ProxyApi) => {
}),
stakingPolicyAndReward: Yup.object().shape({
stakingAmount: BNSchema.test(
minContext('Input must be greater than ${min} for proposal to execute', 'leaderOpeningStake', true, 'execution')
minContext('Input must be at least ${min} for proposal to execute', 'leaderOpeningStake', true, 'execution')
).required('Field is required'),
leavingUnstakingPeriod: BNSchema.test(
minContext(
'Input must be greater than ${min} for proposal to execute',
'Input must be at least ${min} for proposal to execute',
'minUnstakingPeriodLimit',
false,
'execution'
Expand Down

0 comments on commit 349e163

Please sign in to comment.