Skip to content

craig-at-metashield-io/graphql-validation-transformers

Repository files navigation

Add field-level validation for strings and numbers to your Amplify GraphQL schema

graphql-validation-transformers

This is the root of the graphql-validation-transformers package. The subpackages within this include:

Strings

@graphql-validation-transformers/string

String field validation, including min & max length and regex pattern matching

type GenericEntityExample @model()  {
   id: ID!   
   title: String! @xstring(min: 2, max: 128, nows: true)
   summary: String!  @xstring(max: 256, nows: true)
   description: String  @default(value: "") @xstring(max: 1024) 
   tag: String  @xstring(regex: "^[0-9A-Z]{8}$")           
}

see the package's readme.md files for more details

Numbers

@graphql-validation-transformers/number

Number field validation, include min & max value

type GenericEntityExample @model()  {
   percent: Float @xnumber(min: 0, max: 100)
   margin: Float @default(value: "0") @xnumber(min: -10, max: 10)
   index: Int  @default(value: "0") @xnumber(max: 1024)
}

see the package's readme.md files for more details

Requirements

These transformers are designed to work in an AWS Amplify project using the GraphQL transformer v2

Suggestions & Improvements

Please feel free to open a feature request for any additions or improvements you think may add value. I will try to include all those that make sense to me.

Or better yet,

Contribute

Code contributions in the form of pull-requests are most welcome.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •