Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@graphcms/validation

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphcms/validation - npm Package Compare versions

Comparing version 1.0.8 to 1.0.9

.rpt2_cache/f7caad0df29c691cbd221b50dceeef29ed644638/types/cache/195dd9702c190bdc3f6643d19fc3c14f89e20a14

36

dist/enumeration.d.ts

@@ -1,4 +0,38 @@

import * as yup from "yup";
import * as yup from 'yup';
/**
* Matcher for enumeration api IDs:
*
* .string() -> Ensures that only strings can be validated with success
* .typeError(:string)-> Ensures that types other than string return false
* .strict(:boolean) -> Prevents manipulation of the string during validation
* .min() -> Sets minimum required length of string to 1 character
* .max() -> Sets maximum required length of string to 64 characters
* .required() -> Ensures that empty strings are treated as invalid value
* .test() -> Executes an arbitrary test on the input value
* .matches(:RegExpr) -> Matches the input value against a regular expression
*/
export declare const apiId: yup.StringSchema;
/**
* Matcher for enumeration api IDs:
*
* .string() -> Ensures that only strings can be validated with success
* .typeError(:string)-> Ensures that types other than string return false
* .strict(:boolean) -> Prevents manipulation of the string during validation
* .trim() -> Since strict is true, this only validates that the input value is trimmed
* This means that it checks that the value does not have any leading or trailing whitespaces.
* .required() -> Ensures that empty strings are treated as invalid value
*/
export declare const displayName: yup.StringSchema;
/**
* Matcher for enumeration api IDs:
*
* .string() -> Ensures that only strings can be validated with success
* .typeError(:string)-> Ensures that types other than string return false
* .strict(:boolean) -> Prevents manipulation of the string during validation
* .min() -> Sets minimum required length of string to 1 character
* .max() -> Sets maximum required length of string to 64 characters
* .required() -> Ensures that empty strings are treated as invalid value
* .test() -> Executes an arbitrary test on the input value
* .matches(:RegExpr) -> Matches the input value against a regular expression
*/
export declare const value: yup.StringSchema;
import * as yup from 'yup';
/**
* Matcher for field api IDs:
*
* .string() -> Ensures that only strings can be validated with success
* .typeError(:string)-> Ensures that types other than string return false
* .strict(:boolean) -> Prevents manipulation of the string during validation
* .required() -> Ensures that empty strings are treated as invalid value
* .min() -> Sets minimum required length of string to 1 character
* .max() -> Sets maximum required length of string to 32 characters
* .test() -> Executes an arbitrary test on the input value
* .matches(:RegExpr) -> Matches the input value against a regular expression
*/
export declare const apiId: yup.StringSchema;
/**
* Matcher for field display names:
*
* .string() -> Ensures that only strings can be validated with success
* .typeError(:string)-> Ensures that types other than string return false
* .strict(:boolean) -> Prevents manipulation of the string during validation
* .required() -> Ensures that empty strings are treated as invalid value
* .min() -> Sets minimum required length of string to 1 character
* .max() -> Sets maximum required length of string to 32 characters
* .test() -> Executes an arbitrary test on the input value
*/
export declare const displayName: yup.StringSchema;
/**
* Matcher for model descriptions:
*
* .string() -> Ensures that only strings can be validated with success
* .typeError(:string)-> Ensures that types other than string return false
* .ensure() -> Transforms the values "undefined" and "null" into empty strings
*/
export declare const description: yup.StringSchema;

2

dist/index.d.ts
import * as model from './model';
import * as field from './field';
import * as enumeration from './enumeration';
export * from "yup";
export * from 'yup';
export { model, field, enumeration };

@@ -1,3 +0,33 @@

import * as yup from "yup";
import * as yup from 'yup';
/**
* Matcher for model api IDs:
*
* .string() -> Ensures that only strings can be validated with success
* .typeError(:string)-> Ensures that types other than string return false
* .strict(:boolean) -> Prevents manipulation of the string during validation
* .min() -> Sets minimum required length of string to 1 character
* .max() -> Sets maximum required length of string to 64 characters
* .required() -> Ensures that empty strings are treated as invalid value
* .test() -> Executes an arbitrary test on the input value
* .matches(:RegExpr) -> Matches the input value against a regular expression
*/
export declare const apiId: yup.StringSchema;
/**
* Matcher for model display names:
*
* .string() -> Ensures that only strings can be validated with success
* .typeError(:string)-> Ensures that types other than string return false
* .strict(:boolean) -> Prevents manipulation of the string during validation
* .trim() -> Since strict is true, this only validates that the input value is trimmed
* This means that it checks that the value does not have any leading or trailing whitespaces.
* .required() -> Ensures that empty strings are treated as invalid value
*/
export declare const displayName: yup.StringSchema;
/**
* Matcher for model descriptions:
*
* .string() -> Ensures that only strings can be validated with success
* .typeError(:string)-> Ensures that types other than string return false
* .ensure() -> Transforms the values "undefined" and "null" into empty strings
*/
export declare const description: yup.StringSchema;
{
"name": "@graphcms/validation",
"version": "1.0.8",
"version": "1.0.9",
"main": "dist/validation.js",

@@ -32,7 +32,8 @@ "types": "dist/index.d.ts",

"scripts": {
"build": "microbundle",
"build": "microbundle --target browser",
"dev": "microbundle watch",
"test": "jest",
"prepare": "jest",
"prepublish": "microbundle"
"prepublish": "microbundle --target browser",
"format": "prettier \"src/*.*\" --write --list-different"
},

@@ -43,3 +44,6 @@ "devDependencies": {

"microbundle": "^0.4.4",
"prettier": "^1.11.1",
"ts-jest": "^22.4.2",
"tslint": "^5.9.1",
"tslint-config-prettier": "^1.10.0",
"typescript": "^2.8.1"

@@ -46,0 +50,0 @@ },

@@ -6,12 +6,32 @@ # GraphCMS/validation

## Usage (WIP / non-final)
## Usage
Let's say you want to check if some string is a valid model api id.
Here is how you would do that:
```js
import { model } from '@graphcms/validation';
import * as Validator from '@graphcms/validation';
const modelId = "TestModel";
const validationResult = model.apiId.validateSync(modelId);
// validationResult => true
const model = {
apiId: 'TestModel', // The api id of the model in question
displayName: 'TestModel',
description: null,
};
Validator.object()
.shape({
data: Validator.object().shape({
apiId: Validator.model.apiId,
displayName: Validator.model.displayName,
description: Validator.model.description,
}),
})
.validateSync(model, {
abortEarly: false,
});
// Validation SUCCESSFUL
```
If a validation is NOT successful, a `ValidationError` will be thrown.
## API (WIP)
## API

@@ -21,13 +41,19 @@ The export from this module looks like this:

```js
import * as validation from '@graphcms/validation';
var validation = require('@graphcms/validation');
validation: Object
model: Object
apiId: Object
displayName: Object
field: Object
apiId: Object
displayName: Object
/* validation => */ {
validation: Object // The validation package object
enumeration: Object // Validators for various enumeration data
apiId: yup.StringSchema // Validator schema for enumeration api ids
displayName: yup.StringSchema // Validator schema for enumeration display names
value: yup.StringSchema // Validator schema for enumeration entries
field: Object // Validators for various field data
apiId: yup.StringSchema // Validator schema for field api ids
displayName: yup.StringSchema // Validator schema for field display names
model: Object // Validators for various model data
apiId: yup.StringSchema // Validator schema for model api ids
displayName: yup.StringSchema // Validator schema for model display names
yup: Object // The yup.js validation package
}
```

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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