Skip to content

Commit

Permalink
fix: Increase choices limit for turbo (#1043)
Browse files Browse the repository at this point in the history
* fix: Increase choices limit for turbo

* v0.12.4
  • Loading branch information
ChaituVR committed Aug 2, 2024
1 parent 8f07c8c commit 75f1a0b
Show file tree
Hide file tree
Showing 7 changed files with 1,022 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@snapshot-labs/snapshot.js",
"version": "0.12.3",
"version": "0.12.4",
"repository": "snapshot-labs/snapshot.js",
"license": "MIT",
"main": "dist/snapshot.cjs.js",
Expand Down
5 changes: 4 additions & 1 deletion src/schemas/proposal.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
"type": "array",
"title": "choices",
"minItems": 1,
"maxItems": 500
"maxLengthWithSpaceType": {
"default": 500,
"turbo": 1000
}
},
"type": {
"type": "string",
Expand Down
5 changes: 4 additions & 1 deletion src/schemas/update-proposal.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@
"type": "array",
"title": "choices",
"minItems": 1,
"maxItems": 500
"maxLengthWithSpaceType": {
"default": 500,
"turbo": 1000
}
},
"type": {
"enum": [
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ ajv.addKeyword({
validate.errors = [
{
keyword: 'maxLengthWithSpaceType',
message: `must NOT have more than ${schema[spaceType]} characters`,
message: `must not have more than ${schema[spaceType]}`,
params: { limit: schema[spaceType] }
}
];
Expand Down
11 changes: 10 additions & 1 deletion test/examples/proposal-maxLengthWithSpaceType-error.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,19 @@
{
"instancePath": "/body",
"keyword": "maxLengthWithSpaceType",
"message": "must NOT have more than 10000 characters",
"message": "must not have more than 10000",
"params": {
"limit": 10000
},
"schemaPath": "#/properties/body/maxLengthWithSpaceType"
},
{
"instancePath": "/choices",
"keyword": "maxLengthWithSpaceType",
"message": "must not have more than 500",
"params": {
"limit": 500
},
"schemaPath": "#/properties/choices/maxLengthWithSpaceType"
}
]
1,002 changes: 1,000 additions & 2 deletions test/examples/proposal-turbo.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion test/schema.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import schemas from '../src/schemas';
import proposalMaxLengthWithSpaceTypeError from './examples/proposal-maxLengthWithSpaceType-error.json';
import spaceMaxItemsWithSpaceTypeError from './examples/space-maxItemsWithSpaceType-error.json';

// Tests for default spaces
describe.each([
{ schemaType: 'space', schema: schemas.space, example: space },
{ schemaType: 'proposal', schema: schemas.proposal, example: proposal },
Expand All @@ -30,7 +31,6 @@ describe.each([
});

// Tests for turbo spaces

describe.each([
{ schemaType: 'space', schema: schemas.space, example: spaceTurbo },
{ schemaType: 'proposal', schema: schemas.proposal, example: proposalTurbo }
Expand All @@ -44,6 +44,7 @@ describe.each([
});
});

// tests for default schema with turbo example, should fail
describe.each([
{
schemaType: 'space',
Expand Down

0 comments on commit 75f1a0b

Please sign in to comment.