-
-
Notifications
You must be signed in to change notification settings - Fork 60
Closed
Description
I modified the casing of the GraphQL-generated enums to follow EnumName.ENUM_VALUE. When I run typescript-validation-schema to generate the schemas, it always defaults to the original EnumName.EnumValue casing.
My codegen
generates:
types.ts:
plugins:
- 'typescript'
config:
namingConvention:
enumValues: 'change-case-all#upperCase'
validation.ts:
plugins:
- 'typescript-validation-schema'
config:
importFrom: ./types
schema: yupThe outcome of this is the following generated files:
// types.ts
export enum SortDirection {
ASC = 'ASC',
DESC = 'DESC'
}// validation.ts
import * as yup from 'yup'
import { SortDirectionSchema } from './types'
export const SortDirectionSchema = yup.string<SortDirection>().oneOf([SortDirection.Asc, SortDirection.Desc]).defined();However, if the generator would create the following valid yup schema, the casing of the enum values would be irrelevant.
// validation.ts
import * as yup from 'yup'
import { SortDirectionSchema } from './types'
export const SortDirectionSchema = yup.string<SortDirection>().oneOf(Object.values(SortDirection)).defined();Reference discussion: jquense/yup#1013
Metadata
Metadata
Assignees
Labels
No labels