From 51b6d24d0a07e515df8399b3cee2e06b0493fe17 Mon Sep 17 00:00:00 2001 From: jlenon7 Date: Sat, 11 May 2024 12:51:07 +0100 Subject: [PATCH] chore(validator): update return type of extend --- package.json | 2 +- src/index.ts | 2 ++ src/validator/ValidatorImpl.ts | 22 ++++++++++++++++++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 90bd80e..6f6c862 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@athenna/validator", - "version": "4.0.0", + "version": "4.1.0", "description": "Template for new projects.", "license": "MIT", "author": "João Lenon ", diff --git a/src/index.ts b/src/index.ts index 2beb203..dd97666 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,6 +8,7 @@ */ import vine, { + Vine, VineAny, VineDate, VineEnum, @@ -33,6 +34,7 @@ export * from '#src/exceptions/ValidationException' export { vine, + Vine, VineAny, VineDate, VineEnum, diff --git a/src/validator/ValidatorImpl.ts b/src/validator/ValidatorImpl.ts index 52fc7d8..374f45a 100644 --- a/src/validator/ValidatorImpl.ts +++ b/src/validator/ValidatorImpl.ts @@ -7,8 +7,11 @@ * file that was distributed with this source code. */ +/* eslint-disable no-use-before-define */ + import { vine, + Vine, VineAccepted, VineAny, VineArray, @@ -25,6 +28,21 @@ import { import type { ExtendHandlerType } from '#src/types' +type ExtendReturnType = { + accepted: (name: string, handler: ExtendHandlerType) => ValidatorImpl + date: (name: string, handler: ExtendHandlerType) => ValidatorImpl + record: (name: string, handler: ExtendHandlerType) => ValidatorImpl + tuple: (name: string, handler: ExtendHandlerType) => ValidatorImpl + literal: (name: string, handler: ExtendHandlerType) => ValidatorImpl + array: (name: string, handler: ExtendHandlerType) => ValidatorImpl + any: (name: string, handler: ExtendHandlerType) => ValidatorImpl + string: (name: string, handler: ExtendHandlerType) => ValidatorImpl + number: (name: string, handler: ExtendHandlerType) => ValidatorImpl + enum: (name: string, handler: ExtendHandlerType) => ValidatorImpl + boolean: (name: string, handler: ExtendHandlerType) => ValidatorImpl + object: (name: string, handler: ExtendHandlerType) => ValidatorImpl +} + export class ValidatorImpl { /** * This getter will return the vine instance to @@ -38,7 +56,7 @@ export class ValidatorImpl { * }) * ``` */ - public get schema() { + public get schema(): Vine { return vine } @@ -63,7 +81,7 @@ export class ValidatorImpl { * }) * ``` */ - public extend() { + public extend(): ExtendReturnType { const macro = (Vine: any, name: string, handler: any) => { Vine.macro(name, handler) }