@envelop/extended-validation
Advanced tools
Comparing version 1.7.0 to 1.7.1-alpha-72027859.0
@@ -21,6 +21,4 @@ "use strict"; | ||
const isOneOfFieldType = ((_b = fieldType.extensions) === null || _b === void 0 ? void 0 : _b.oneOf) || (fieldType.astNode && (0, common_js_1.getDirectiveFromAstNode)(fieldType.astNode, 'oneOf')); | ||
if (isOneOfFieldType) { | ||
if (Object.keys(values).length !== 1) { | ||
validationContext.reportError(new graphql_1.GraphQLError(`Exactly one key must be specified for input for field "${fieldType.type.toString()}.${node.name.value}"`, [node])); | ||
} | ||
if (isOneOfFieldType && Object.keys(values).length !== 1) { | ||
validationContext.reportError(new graphql_1.GraphQLError(`Exactly one key must be specified for input for field "${fieldType.type.toString()}.${node.name.value}"`, [node])); | ||
} | ||
@@ -68,6 +66,4 @@ for (const arg of node.arguments) { | ||
const isOneOfInputType = ((_a = inputType.extensions) === null || _a === void 0 ? void 0 : _a.oneOf) || (inputType.astNode && (0, common_js_1.getDirectiveFromAstNode)(inputType.astNode, 'oneOf')); | ||
if (isOneOfInputType) { | ||
if (Object.keys(currentValue).length !== 1) { | ||
validationContext.reportError(new graphql_1.GraphQLError(`Exactly one key must be specified for input type "${inputType.name}"`, [arg])); | ||
} | ||
if (isOneOfInputType && Object.keys(currentValue).length !== 1) { | ||
validationContext.reportError(new graphql_1.GraphQLError(`Exactly one key must be specified for input type "${inputType.name}"`, [arg])); | ||
} | ||
@@ -74,0 +70,0 @@ if (inputType instanceof graphql_1.GraphQLInputObjectType) { |
@@ -18,6 +18,4 @@ import { GraphQLError, GraphQLInputObjectType, GraphQLNonNull, isListType, getNamedType, } from 'graphql'; | ||
const isOneOfFieldType = ((_b = fieldType.extensions) === null || _b === void 0 ? void 0 : _b.oneOf) || (fieldType.astNode && getDirectiveFromAstNode(fieldType.astNode, 'oneOf')); | ||
if (isOneOfFieldType) { | ||
if (Object.keys(values).length !== 1) { | ||
validationContext.reportError(new GraphQLError(`Exactly one key must be specified for input for field "${fieldType.type.toString()}.${node.name.value}"`, [node])); | ||
} | ||
if (isOneOfFieldType && Object.keys(values).length !== 1) { | ||
validationContext.reportError(new GraphQLError(`Exactly one key must be specified for input for field "${fieldType.type.toString()}.${node.name.value}"`, [node])); | ||
} | ||
@@ -64,6 +62,4 @@ for (const arg of node.arguments) { | ||
const isOneOfInputType = ((_a = inputType.extensions) === null || _a === void 0 ? void 0 : _a.oneOf) || (inputType.astNode && getDirectiveFromAstNode(inputType.astNode, 'oneOf')); | ||
if (isOneOfInputType) { | ||
if (Object.keys(currentValue).length !== 1) { | ||
validationContext.reportError(new GraphQLError(`Exactly one key must be specified for input type "${inputType.name}"`, [arg])); | ||
} | ||
if (isOneOfInputType && Object.keys(currentValue).length !== 1) { | ||
validationContext.reportError(new GraphQLError(`Exactly one key must be specified for input type "${inputType.name}"`, [arg])); | ||
} | ||
@@ -70,0 +66,0 @@ if (inputType instanceof GraphQLInputObjectType) { |
{ | ||
"name": "@envelop/extended-validation", | ||
"version": "1.7.0", | ||
"version": "1.7.1-alpha-72027859.0", | ||
"sideEffects": false, | ||
"peerDependencies": { | ||
"@envelop/core": "^2.4.0", | ||
"@envelop/core": "2.4.1-alpha-72027859.0", | ||
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0" | ||
@@ -8,0 +8,0 @@ }, |
@@ -20,3 +20,3 @@ ## `@envelop/extended-validation` | ||
```ts | ||
import { useExtendedValidation } from '@envelop/extended-validation'; | ||
import { useExtendedValidation } from '@envelop/extended-validation' | ||
@@ -26,3 +26,5 @@ const getEnveloped = evelop({ | ||
useExtendedValidation({ | ||
rules: [ ... ] // your rules here | ||
rules: [ | ||
/* ... your rules here */ | ||
] | ||
}) | ||
@@ -38,3 +40,3 @@ ] | ||
```ts | ||
import { ExtendedValidationRule } from '@envelop/extended-validation'; | ||
import { ExtendedValidationRule } from '@envelop/extended-validation' | ||
@@ -47,5 +49,5 @@ export const MyRule: ExtendedValidationRule = (validationContext, executionArgs) => { | ||
// If you wish to report an error, use validationContext.reportError or throw an exception. | ||
}, | ||
}; | ||
}; | ||
} | ||
} | ||
} | ||
``` | ||
@@ -64,3 +66,3 @@ | ||
```ts | ||
import { useExtendedValidation, OneOfInputObjectsRule } from '@envelop/extended-validation'; | ||
import { useExtendedValidation, OneOfInputObjectsRule } from '@envelop/extended-validation' | ||
@@ -70,6 +72,6 @@ const getEnveloped = evelop({ | ||
useExtendedValidation({ | ||
rules: [OneOfInputObjectsRule], | ||
}), | ||
], | ||
}); | ||
rules: [OneOfInputObjectsRule] | ||
}) | ||
] | ||
}) | ||
``` | ||
@@ -108,12 +110,12 @@ | ||
id: { | ||
type: GraphQLID, | ||
type: GraphQLID | ||
}, | ||
organizationAndRegistrationNumber: { | ||
type: GraphQLInt, | ||
}, | ||
type: GraphQLInt | ||
} | ||
}, | ||
extensions: { | ||
oneOf: true, | ||
}, | ||
}); | ||
oneOf: true | ||
} | ||
}) | ||
@@ -127,17 +129,17 @@ const Query = new GraphQLObjectType({ | ||
id: { | ||
type: GraphQLID, | ||
type: GraphQLID | ||
}, | ||
str1: { | ||
type: GraphQLString, | ||
type: GraphQLString | ||
}, | ||
str2: { | ||
type: GraphQLString, | ||
}, | ||
type: GraphQLString | ||
} | ||
}, | ||
extensions: { | ||
oneOf: true, | ||
}, | ||
}, | ||
}, | ||
}); | ||
oneOf: true | ||
} | ||
} | ||
} | ||
}) | ||
``` |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
138
21221
332
2