mirror of
https://github.com/muerwre/vk-tg-bot.git
synced 2025-04-24 22:46:41 +07:00
initial
This commit is contained in:
commit
ddefc2743a
21 changed files with 873 additions and 0 deletions
20
src/service/vk/validation.ts
Normal file
20
src/service/vk/validation.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
import * as yup from 'yup'
|
||||
import { VkConfig, VkEvent } from './types';
|
||||
|
||||
const vkChannelEventSchema = yup.string().oneOf(Object.values(VkEvent))
|
||||
|
||||
const vkChannelSchema = yup.object().required().shape({
|
||||
id: yup.string().required().matches(/^@/, ({ path }) => `${path} should start with "@"`),
|
||||
events: yup.array().of(vkChannelEventSchema)
|
||||
})
|
||||
|
||||
export const vkConfigSchema = yup.object<VkConfig>().required().shape({
|
||||
groups: yup.array().required().of(yup.object().shape({
|
||||
id: yup.number().positive(),
|
||||
name: yup.string().required(),
|
||||
testResponse: yup.string().required(),
|
||||
secretKey: yup.string().required(),
|
||||
apiKey: yup.string().required(),
|
||||
channels: yup.array().of(vkChannelSchema),
|
||||
}))
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue