diff --git a/src/schemas/proposal.json b/src/schemas/proposal.json index 58a23616d..cab93398f 100644 --- a/src/schemas/proposal.json +++ b/src/schemas/proposal.json @@ -15,11 +15,7 @@ "body": { "type": "string", "title": "body", - "minLength": 0, - "maxLengthWithSpaceType": { - "default": 10000, - "turbo": 40000 - } + "minLength": 0 }, "discussion": { "type": "string", @@ -30,11 +26,7 @@ "choices": { "type": "array", "title": "choices", - "minItems": 1, - "maxLengthWithSpaceType": { - "default": 500, - "turbo": 1000 - } + "minItems": 1 }, "labels": { "type": "array", diff --git a/src/schemas/space.json b/src/schemas/space.json index cc3058e30..667f95648 100644 --- a/src/schemas/space.json +++ b/src/schemas/space.json @@ -120,10 +120,6 @@ "strategies": { "type": "array", "minItems": 1, - "maxItemsWithSpaceType": { - "default": 8, - "turbo": 10 - }, "uniqueItems": true, "items": { "type": "object", diff --git a/src/schemas/update-proposal.json b/src/schemas/update-proposal.json index e565d7587..2b98138fa 100644 --- a/src/schemas/update-proposal.json +++ b/src/schemas/update-proposal.json @@ -19,11 +19,7 @@ "body": { "type": "string", "title": "body", - "minLength": 0, - "maxLengthWithSpaceType": { - "default": 10000, - "turbo": 20000 - } + "minLength": 0 }, "discussion": { "type": "string", @@ -34,11 +30,7 @@ "choices": { "type": "array", "title": "choices", - "minItems": 1, - "maxLengthWithSpaceType": { - "default": 500, - "turbo": 1000 - } + "minItems": 1 }, "labels": { "type": "array", diff --git a/src/utils.ts b/src/utils.ts index 3d4b8797e..bc3f4d1a8 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -194,48 +194,6 @@ ajv.addKeyword({ } }); -ajv.addKeyword({ - keyword: 'maxLengthWithSpaceType', - validate: function validate(schema, data) { - // @ts-ignore - const spaceType = this.spaceType || 'default'; - const isValid = data.length <= schema[spaceType]; - if (!isValid) { - // @ts-ignore - validate.errors = [ - { - keyword: 'maxLengthWithSpaceType', - message: `must not have more than ${schema[spaceType]}`, - params: { limit: schema[spaceType] } - } - ]; - } - return isValid; - }, - errors: true -}); - -ajv.addKeyword({ - keyword: 'maxItemsWithSpaceType', - validate: function validate(schema, data) { - // @ts-ignore - const spaceType = this.spaceType || 'default'; - const isValid = data.length <= schema[spaceType]; - if (!isValid) { - // @ts-ignore - validate.errors = [ - { - keyword: 'maxItemsWithSpaceType', - message: `must NOT have more than ${schema[spaceType]} items`, - params: { limit: schema[spaceType] } - } - ]; - } - return isValid; - }, - errors: true -}); - // Custom URL format to allow empty string values // https://github.com/snapshot-labs/snapshot.js/pull/541/files ajv.addFormat('customUrl', { diff --git a/test/examples/proposal-maxLengthWithSpaceType-error.json b/test/examples/proposal-maxLengthWithSpaceType-error.json deleted file mode 100644 index 8e16d590a..000000000 --- a/test/examples/proposal-maxLengthWithSpaceType-error.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - { - "instancePath": "/body", - "keyword": "maxLengthWithSpaceType", - "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" - } -] diff --git a/test/examples/space-maxItemsWithSpaceType-error.json b/test/examples/space-maxItemsWithSpaceType-error.json deleted file mode 100644 index 9c1307668..000000000 --- a/test/examples/space-maxItemsWithSpaceType-error.json +++ /dev/null @@ -1,11 +0,0 @@ -[ - { - "instancePath": "/strategies", - "keyword": "maxItemsWithSpaceType", - "message": "must NOT have more than 8 items", - "params": { - "limit": 8 - }, - "schemaPath": "#/properties/strategies/maxItemsWithSpaceType" - } -] diff --git a/test/schema.spec.ts b/test/schema.spec.ts index 2abd2b60f..479f5807e 100644 --- a/test/schema.spec.ts +++ b/test/schema.spec.ts @@ -10,8 +10,6 @@ import profile from './examples/profile.json'; import statement from './examples/statement.json'; import alias from './examples/alias.json'; 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([ @@ -49,29 +47,3 @@ describe.each([ expect(isValid).toBe(true); }); }); - -// tests for default schema with turbo example, should fail -describe.each([ - { - schemaType: 'space', - schema: schemas.space, - example: spaceTurbo, - error: spaceMaxItemsWithSpaceTypeError - }, - { - schemaType: 'proposal', - schema: schemas.proposal, - example: proposalTurbo, - error: proposalMaxLengthWithSpaceTypeError - } -])( - `Run validate for default schema with turbo example`, - ({ schemaType, schema, example, error }) => { - test(`validating schema ${schemaType} should fail with error`, () => { - const isValid = validateSchema(schema, example, { - snapshotEnv: 'mainnet' - }); - expect(isValid).toMatchObject(error); - }); - } -);