import { Query, Resolver } from '@nestjs/graphql' import { targetConstructorToSchema }…
- User
import { Query, Resolver } from '@nestjs/graphql' import { targetConstructorToSchema } from 'class-validator-jsonschema' import { CreateTicketTierInput } from 'src/ticket-tiers/dto/create-ticket-tier.input' import GraphQLJSON from 'graphql-type-json'
@Resolver() export class ValidationSchemaResolver { @Query(() => GraphQLJSON, { description: 'Fetch validation schema for creating a ticket tier', }) createTicketTier(): object { const schema = targetConstructorToSchema(CreateTicketTierInput, { additionalConverters: { charactersCategory: (meta) => { console.log('meta', meta) return { charactersRegex: { source: 'should go here', flags: 'gmu', }, } }, }, })
return schema} }
import { ValidatorConstraint, ValidatorConstraintInterface, } from 'class-validator' import messages from 'src/common/messages/messages' import { charactersCategoryRegex } from './utils/regex'
@ValidatorConstraint({ name: 'charactersCategory', async: false }) export class CustomCharactersValidation implements ValidatorConstraintInterface { validate(value: string): boolean { return !charactersCategoryRegex().test(value) }
defaultMessage(): string { return messages.validation.common.InvalidCharacters.id } }
import emojiRegexFunction from 'emoji-regex'
const wordsBlackListRegex = (item) => new RegExp(
\\b${item}\\b, 'i') const spacesOnlyRegex = () => /^(?!\s*/gmu const capsPercentRegex = () => /[\p{Lu}]/gmu const emojiRegex = emojiRegexFunction - Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.