# nexus-plugin-arguments-validation

> ```bash yarn add nexus-plugin-arguments-validation ```

Latest version **0.0.0-preview-4** (published 2020-07-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install nexus-plugin-arguments-validation
pnpm add nexus-plugin-arguments-validation
yarn add nexus-plugin-arguments-validation
bun add nexus-plugin-arguments-validation
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.0-preview-4 |
| Published | 2020-07-29 |
| First published | 2020-04-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 206.2 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Lukáš Huvar |
| Maintainers | huvik |

## Links

- npm: https://www.npmjs.com/package/nexus-plugin-arguments-validation
- npm.io page: https://npm.io/package/nexus-plugin-arguments-validation

## Dependencies (3)

- [nexus](https://npm.io/package/nexus.md) ^0.20.0
- [set-value](https://npm.io/package/set-value.md) 3.0.1
- [@nexus/schema](https://npm.io/package/@nexus/schema.md) ^0.14.0-next.1

## Recent versions

- 0.0.0-preview-4 (latest) — 2020-07-29
- 0.0.0-preview-3 — 2020-07-29
- 0.0.0-preview-2 — 2020-04-28
- 0.0.0-preview-1 — 2020-04-19

## README

<p align="center">
  <h1 align="center">nexus-plugin-arguments-validation</h1>
</p>

`nexus-plugin-arguments-validation` is a [Nexus](https://github.com/prisma-labs/nexus) plugin for arguments validation with [Yup](https://github.com/jquense/yup).

![build](https://github.com/huv1k/nexus-plugin-arguments-validation/workflows/Build%20and%20test/badge.svg)
[![downloads](https://img.shields.io/npm/dt/nexus-plugin-arguments-validation.svg)](https://npmjs.org/package/nexus-plugin-arguments-validation?cacheSeconds=3600)
[![version](https://img.shields.io/npm/v/nexus-plugin-arguments-validation.svg)](https://npmjs.org/package/nexus-plugin-arguments-validation?cacheSeconds=3600)

## Installation

```bash
yarn add nexus-plugin-arguments-validation
```

## Example

```typescript
import { join } from 'path'
import { ApolloServer } from 'apollo-server'
import { makeSchema, mutationField, stringArg } from '@nexus/schema'
import { object, string } from 'yup'
import { argumentsValidationPlugin } from 'nexus-plugin-arguments-validation/schema'

const ValidateUrl = object().shape({
  url: string().url('Your url is not valid!'),
})

const types = [
  mutationField('validateUrl', {
    type: 'String',
    description: 'Validates the url argument as a valid URL via a regex',
    args: {
      url: stringArg(),
    },
    // @ts-ignore
    validateArgs: ValidateUrl,
    resolve: (_, { url }) => {
      return `Your url: ${url} is valid!`
    },
  }),
]

const schema = makeSchema({
  types,
  plugins: [argumentsValidationPlugin()],
  outputs: {
    schema: join(__dirname, 'generated/schema.graphql'),
    typegen: join(__dirname, 'generated/nexus.ts'),
  },
})

new ApolloServer({
  schema,
}).listen({ port: 4000 }, () =>
  console.log(`🚀 Server ready at: http://localhost:4000`),
)
```

---
_Source: https://npm.io/package/nexus-plugin-arguments-validation · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
