Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(validator): update return type of extend #1

Merged
merged 1 commit into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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 <lenon@athenna.io>",
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

import vine, {
Vine,
VineAny,
VineDate,
VineEnum,
Expand All @@ -33,6 +34,7 @@ export * from '#src/exceptions/ValidationException'

export {
vine,
Vine,
VineAny,
VineDate,
VineEnum,
Expand Down
22 changes: 20 additions & 2 deletions src/validator/ValidatorImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
* file that was distributed with this source code.
*/

/* eslint-disable no-use-before-define */

import {
vine,
Vine,
VineAccepted,
VineAny,
VineArray,
Expand All @@ -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
Expand All @@ -38,7 +56,7 @@ export class ValidatorImpl {
* })
* ```
*/
public get schema() {
public get schema(): Vine {
return vine
}

Expand All @@ -63,7 +81,7 @@ export class ValidatorImpl {
* })
* ```
*/
public extend() {
public extend(): ExtendReturnType {
const macro = (Vine: any, name: string, handler: any) => {
Vine.macro(name, handler)
}
Expand Down
Loading