adonisjs / validator

Schema based validator for AdonisJS
MIT License
116 stars 39 forks source link

rules.Range() does not work #88

Closed fnoquiq closed 4 years ago

fnoquiq commented 4 years ago

When using the following code: schema.number([rules.range(10, 100)]), an error appears.

The error: Property 'range' does not exist on type 'Rules'.ts(2339).

I'm following the same tutorial on the site -> https://preview.adonisjs.com/guides/validator/schema-types

Captura de Tela 2020-07-07 às 15 30 18

Package version

{
    "@adonisjs/ace": "^6.0.0",
    "@adonisjs/auth": "^4.2.4",
    "@adonisjs/core": "^5.0.0-preview-rc",
    "@adonisjs/fold": "^6.0.0",
    "@adonisjs/lucid": "^8.2.2",
}

Node.js and npm version

Nodejs: 12.18.2 Npm: 6.14.5 Yarn: 1.22.4

Sample Code (to reproduce the issue)

import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
import { schema, rules } from '@ioc:Adonis/Core/Validator'

export default class StoreValidator {
  constructor(private ctx: HttpContextContract) { }

  public schema = schema.create({
    testNumber: schema.number([rules.unsigned(), rules.range(10, 100)])
  })

  public cacheKey = this.ctx.routeKey

  public messages = {}
}

BONUS (a sample repo to reproduce the issue)

Sample repo -> https://github.com/fnoquiq/adonis-validator-issue-range-example

thetutlage commented 4 years ago

Thanks for reporting. Seems to be missing

Xstoudi commented 4 years ago

Can I make a PR? @thetutlage

thetutlage commented 4 years ago

Sure, feel free to do that. I will release it right away

Xstoudi commented 4 years ago

Here it is @thetutlage #89 :)