Socket
Socket
Sign inDemoInstall

@zeit/schemas

Package Overview
Dependencies
Maintainers
146
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zeit/schemas - npm Package Compare versions

Comparing version 2.19.0 to 2.20.0

2

package.json
{
"name": "@zeit/schemas",
"version": "2.19.0",
"version": "2.20.0",
"description": "All schemas used for validation that are shared between our projects",

@@ -5,0 +5,0 @@ "scripts": {

@@ -1,14 +0,10 @@

# ZEIT's schemas
# Vercel Schemas
[![Build Status](https://circleci.com/gh/zeit/schemas.svg?&style=shield)](https://circleci.com/gh/zeit/schemas)
[![Join the community on Spectrum](https://withspectrum.github.io/badge/badge.svg)](https://spectrum.chat/zeit)
Schemas used across many Vercel packages to validating config files, requests to APIs, and more.
The schemas contained within this package are used all across the ZEIT ecosystem to validate config files, requests to APIs and more. It ensures users always send just the right data.
## Why?
It is important that these schemas stay in sync between projects, so that the validations are always performed in the same way for the same kind of object.
- Keep schemas used across Vercel projects in sync
- We use `.js` instead of `.json` because parsing JSON takes longer
The files located in this repository are `.js` and not `.json`, because parsing JSON takes a little bit longer.
## Usage

@@ -39,8 +35,2 @@

1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device
2. Link the package to the global module directory: `npm link`
3. Within the module you want to test your local development instance of `@zeit/schemas`, just link it to the dependencies: `npm link @zeit/schemas` and load it!
## Author
Leo Lamprecht ([@notquiteleo](https://twitter.com/notquiteleo)) - [ZEIT](https://zeit.co)
We are currently not accepting external contributions for this repository.
/* eslint camelcase: 0 */
const AJV = require('ajv');
const assert = require('assert');
const {User} = require('../user');
const { User } = require('../user');
const ajv = new AJV({allErrors: true});
const ajv = new AJV({ allErrors: true });

@@ -11,3 +11,3 @@ // Username

const isValid = ajv.validate(User, {
username: null
username: null,
});

@@ -22,3 +22,3 @@ assert.equal(isValid, false);

const isValid = ajv.validate(User, {
username: '!!!'
username: '!!!',
});

@@ -28,3 +28,6 @@ assert.equal(isValid, false);

assert.equal(ajv.errors[0].dataPath, '.username');
assert.equal(ajv.errors[0].message, 'should match pattern "^[a-z0-9][a-z0-9-]*[a-z0-9]$"');
assert.equal(
ajv.errors[0].message,
'should match pattern "^[a-z0-9][a-z0-9-]*[a-z0-9]$"'
);
};

@@ -34,3 +37,3 @@

const isValid = ajv.validate(User, {
username: ''
username: '',
});

@@ -40,5 +43,11 @@ assert.equal(isValid, false);

assert.equal(ajv.errors[0].dataPath, '.username');
assert.equal(ajv.errors[0].message, 'should NOT be shorter than 1 characters');
assert.equal(
ajv.errors[0].message,
'should NOT be shorter than 1 characters'
);
assert.equal(ajv.errors[1].dataPath, '.username');
assert.equal(ajv.errors[1].message, 'should match pattern "^[a-z0-9][a-z0-9-]*[a-z0-9]$"');
assert.equal(
ajv.errors[1].message,
'should match pattern "^[a-z0-9][a-z0-9-]*[a-z0-9]$"'
);
};

@@ -48,3 +57,3 @@

const isValid = ajv.validate(User, {
username: 'a'.repeat(50)
username: 'a'.repeat(50),
});

@@ -54,8 +63,11 @@ assert.equal(isValid, false);

assert.equal(ajv.errors[0].dataPath, '.username');
assert.equal(ajv.errors[0].message, 'should NOT be longer than 48 characters');
assert.equal(
ajv.errors[0].message,
'should NOT be longer than 48 characters'
);
};
exports.test_username_valid = () => {
assert(ajv.validate(User, {username: 'n8'}));
assert(ajv.validate(User, {username: 'rauchg'}));
assert(ajv.validate(User, { username: 'n8' }));
assert(ajv.validate(User, { username: 'rauchg' }));
};

@@ -66,3 +78,3 @@

const isValid = ajv.validate(User, {
name: ''
name: '',
});

@@ -72,3 +84,6 @@ assert.equal(isValid, false);

assert.equal(ajv.errors[0].dataPath, '.name');
assert.equal(ajv.errors[0].message, 'should NOT be shorter than 1 characters');
assert.equal(
ajv.errors[0].message,
'should NOT be shorter than 1 characters'
);
};

@@ -78,3 +93,3 @@

const isValid = ajv.validate(User, {
name: 'a'.repeat(50)
name: 'a'.repeat(50),
});

@@ -84,7 +99,10 @@ assert.equal(isValid, false);

assert.equal(ajv.errors[0].dataPath, '.name');
assert.equal(ajv.errors[0].message, 'should NOT be longer than 32 characters');
assert.equal(
ajv.errors[0].message,
'should NOT be longer than 32 characters'
);
};
exports.test_name_valid = () => {
assert(ajv.validate(User, {name: 'Nate'}));
assert(ajv.validate(User, { name: 'Nate' }));
};

@@ -95,3 +113,3 @@

const isValid = ajv.validate(User, {
billingChecked: null
billingChecked: null,
});

@@ -105,3 +123,3 @@ assert.equal(isValid, false);

exports.test_billing_checked_valid = () => {
assert(ajv.validate(User, {billingChecked: true}));
assert(ajv.validate(User, { billingChecked: true }));
};

@@ -112,3 +130,3 @@

const isValid = ajv.validate(User, {
avatar: 'abc'
avatar: 'abc',
});

@@ -118,3 +136,6 @@ assert.equal(isValid, false);

assert.equal(ajv.errors[0].dataPath, '.avatar');
assert.equal(ajv.errors[0].message, 'should NOT be shorter than 40 characters');
assert.equal(
ajv.errors[0].message,
'should NOT be shorter than 40 characters'
);
};

@@ -124,3 +145,3 @@

const isValid = ajv.validate(User, {
avatar: 'a'.repeat(50)
avatar: 'a'.repeat(50),
});

@@ -130,3 +151,6 @@ assert.equal(isValid, false);

assert.equal(ajv.errors[0].dataPath, '.avatar');
assert.equal(ajv.errors[0].message, 'should NOT be longer than 40 characters');
assert.equal(
ajv.errors[0].message,
'should NOT be longer than 40 characters'
);
};

@@ -136,3 +160,3 @@

const isValid = ajv.validate(User, {
avatar: 'n'.repeat(40)
avatar: 'n'.repeat(40),
});

@@ -146,7 +170,7 @@ assert.equal(isValid, false);

exports.test_avatar_valid = () => {
assert(ajv.validate(User, {avatar: 'a'.repeat(40)}));
assert(ajv.validate(User, { avatar: 'a'.repeat(40) }));
};
exports.test_email_valid = () => {
assert(ajv.validate(User, {email: 'nate@zeit.co'}));
assert(ajv.validate(User, { email: 'nate@zeit.co' }));
};

@@ -156,3 +180,3 @@

const isValid = ajv.validate(User, {
email: `${'n'.repeat(256)}@zeit.co`
email: `${'n'.repeat(256)}@zeit.co`,
});

@@ -163,7 +187,7 @@ assert.equal(isValid, false);

exports.test_avatar_invalid_length = () => {
assert(ajv.validate(User, {avatar: 'a'.repeat(40)}));
assert(ajv.validate(User, { avatar: 'a'.repeat(40) }));
};
exports.test_platformVersion_null_valid = () => {
assert(ajv.validate(User, {platformVersion: null}));
assert(ajv.validate(User, { platformVersion: null }));
};

@@ -173,3 +197,3 @@

const isValid = ajv.validate(User, {
platformVersion: 0
platformVersion: 0,
});

@@ -180,7 +204,7 @@ assert.equal(isValid, false);

exports.test_platformVersion_one_valid = () => {
assert(ajv.validate(User, {platformVersion: 1}));
assert(ajv.validate(User, { platformVersion: 1 }));
};
exports.test_platformVersion_two_valid = () => {
assert(ajv.validate(User, {platformVersion: 2}));
assert(ajv.validate(User, { platformVersion: 2 }));
};

@@ -190,3 +214,3 @@

const isValid = ajv.validate(User, {
platformVersion: 3
platformVersion: 3,
});

@@ -197,15 +221,15 @@ assert.equal(isValid, false);

exports.test_importFlowGitProvider_github_valid = () => {
assert(ajv.validate(User, {importFlowGitProvider: 'github'}));
assert(ajv.validate(User, { importFlowGitProvider: 'github' }));
};
exports.test_importFlowGitProvider_gitlab_valid = () => {
assert(ajv.validate(User, {importFlowGitProvider: 'gitlab'}));
assert(ajv.validate(User, { importFlowGitProvider: 'gitlab' }));
};
exports.test_importFlowGitProvider_bitbucket_valid = () => {
assert(ajv.validate(User, {importFlowGitProvider: 'bitbucket'}));
assert(ajv.validate(User, { importFlowGitProvider: 'bitbucket' }));
};
exports.test_importFlowGitProvider_null_valid = () => {
assert(ajv.validate(User, {importFlowGitProvider: null}));
assert(ajv.validate(User, { importFlowGitProvider: null }));
};

@@ -215,3 +239,3 @@

const isValid = ajv.validate(User, {
importFlowGitProvider: 'test'
importFlowGitProvider: 'test',
});

@@ -223,3 +247,3 @@ assert.equal(isValid, false);

const isValid = ajv.validate(User, {
importFlowGitProvider: 10
importFlowGitProvider: 10,
});

@@ -229,9 +253,8 @@ assert.equal(isValid, false);

exports.test_importFlowGitNamespace_string_valid = () => {
assert(ajv.validate(User, {importFlowGitNamespace: 'test'}));
assert(ajv.validate(User, { importFlowGitNamespace: 'test' }));
};
exports.test_importFlowGitNamespace_null_valid = () => {
assert(ajv.validate(User, {importFlowGitNamespace: null}));
assert(ajv.validate(User, { importFlowGitNamespace: null }));
};

@@ -241,3 +264,3 @@

const isValid = ajv.validate(User, {
importFlowGitNamespace: 10
importFlowGitNamespace: 10,
});

@@ -249,3 +272,3 @@ assert.strictEqual(isValid, false);

const isValid = ajv.validate(User, {
importFlowGitNamespace: true
importFlowGitNamespace: true,
});

@@ -256,11 +279,11 @@ assert.strictEqual(isValid, false);

exports.test_importFlowGitNamespaceId_string_valid = () => {
assert(ajv.validate(User, {importFlowGitNamespaceId: 'test'}));
assert(ajv.validate(User, { importFlowGitNamespaceId: 'test' }));
};
exports.test_importFlowGitNamespaceId_number_valid = () => {
assert(ajv.validate(User, {importFlowGitNamespaceId: 10}));
assert(ajv.validate(User, { importFlowGitNamespaceId: 10 }));
};
exports.test_importFlowGitNamespaceId_null_valid = () => {
assert(ajv.validate(User, {importFlowGitNamespaceId: null}));
assert(ajv.validate(User, { importFlowGitNamespaceId: null }));
};

@@ -270,3 +293,3 @@

const isValid = ajv.validate(User, {
importFlowGitNamespaceId: true
importFlowGitNamespaceId: true,
});

@@ -277,3 +300,3 @@ assert.strictEqual(isValid, false);

exports.test_scopeId_valid = () => {
assert(ajv.validate(User, {scopeId: '123test'}));
assert(ajv.validate(User, { scopeId: '123test' }));
};

@@ -283,3 +306,3 @@

const isValid = ajv.validate(User, {
scopeId: null
scopeId: null,
});

@@ -290,11 +313,11 @@ assert.strictEqual(isValid, false);

exports.test_gitNamespaceId_string_valid = () => {
assert(ajv.validate(User, {gitNamespaceId: 'test'}));
assert(ajv.validate(User, { gitNamespaceId: 'test' }));
};
exports.test_gitNamespaceId_number_valid = () => {
assert(ajv.validate(User, {gitNamespaceId: 123}));
assert(ajv.validate(User, { gitNamespaceId: 123 }));
};
exports.test_gitNamespaceId_null_valid = () => {
assert(ajv.validate(User, {gitNamespaceId: null}));
assert(ajv.validate(User, { gitNamespaceId: null }));
};

@@ -304,3 +327,3 @@

const isValid = ajv.validate(User, {
gitNamespaceId: true
gitNamespaceId: true,
});

@@ -310,1 +333,9 @@ assert.strictEqual(isValid, false);

exports.test_remoteCaching_valid = () => {
assert(ajv.validate(User, { remoteCaching: { enabled: true } }));
};
exports.test_remoteCaching_valid = () => {
const isValid = ajv.validate(User, { remoteCaching: { enabled: 'yes' } });
assert.strictEqual(isValid, false);
};

@@ -5,3 +5,3 @@ const Username = {

maxLength: 48,
pattern: '^[a-z0-9][a-z0-9-]*[a-z0-9]$'
pattern: '^[a-z0-9][a-z0-9-]*[a-z0-9]$',
};

@@ -12,3 +12,3 @@

minLength: 1,
maxLength: 32
maxLength: 32,
};

@@ -19,3 +19,3 @@

minLength: 5,
maxLength: 256
maxLength: 256,
};

@@ -26,8 +26,8 @@

{
'enum': ['github', 'gitlab', 'bitbucket']
enum: ['github', 'gitlab', 'bitbucket'],
},
{
type: 'null'
}
]
type: 'null',
},
],
};

@@ -38,8 +38,8 @@

{
type: 'string'
type: 'string',
},
{
type: 'null'
}
]
type: 'null',
},
],
};

@@ -50,15 +50,15 @@

{
type: 'string'
type: 'string',
},
{
type: 'number'
type: 'number',
},
{
type: 'null'
}
]
type: 'null',
},
],
};
const ScopeId = {
type: 'string'
type: 'string',
};

@@ -69,11 +69,11 @@

{
type: 'string'
type: 'string',
},
{
type: 'number'
type: 'number',
},
{
type: 'null'
}
]
type: 'null',
},
],
};

@@ -85,3 +85,3 @@

// A `null` platform version means to always use the latest
type: 'null'
type: 'null',
},

@@ -91,5 +91,5 @@ {

minimum: 1,
maximum: 2
}
]
maximum: 2,
},
],
};

@@ -101,7 +101,7 @@

maxLength: 40,
pattern: '^[0-9a-f]+$'
pattern: '^[0-9a-f]+$',
};
const Bio = {
type: 'string'
type: 'string',
};

@@ -112,3 +112,3 @@

minLength: 4,
maxLength: 40
maxLength: 40,
};

@@ -120,9 +120,9 @@

service: {
type: 'string'
type: 'string',
},
link: {
type: 'string'
}
type: 'string',
},
},
additionalProperties: false
additionalProperties: false,
};

@@ -136,5 +136,15 @@

items: Profile,
additionalProperties: false
additionalProperties: false,
};
const RemoteCaching = {
type: 'object',
properties: {
enabled: {
type: 'boolean',
},
},
additionalProperties: false,
};
const User = {

@@ -147,3 +157,3 @@ type: 'object',

email: Email,
billingChecked: {type: 'boolean'},
billingChecked: { type: 'boolean' },
avatar: Avatar,

@@ -158,4 +168,5 @@ platformVersion: PlatformVersion,

scopeId: ScopeId,
gitNamespaceId: GitNamespaceId
}
gitNamespaceId: GitNamespaceId,
remoteCaching: RemoteCaching,
},
};

@@ -174,3 +185,3 @@

ScopeId,
GitNamespaceId
GitNamespaceId,
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc