Skip to content

Commit

Permalink
Merge pull request #1 from AthennaIO/develop
Browse files Browse the repository at this point in the history
chore(validator): update return type of extend
  • Loading branch information
jlenon7 authored May 11, 2024
2 parents 89207bd + 51b6d24 commit f7cc004
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
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

0 comments on commit f7cc004

Please sign in to comment.