These are chat archives for dry-rb/chat

22nd
Mar 2018
Hamza Khan-Cheema
@hamzakc
Mar 22 2018 06:10
What tools are people were using for API documentation. I have used swagger::blocks before (https://github.com/fotinakis/swagger-blocks) Anyone using anything else in a dry-web app ?
Semyon Pupkov
@artofhuman
Mar 22 2018 08:55

Hi, i have question about dynamic arguments in dry-v schema

I try to define schema

        CreateSchema = Dry::Validation.Form do
          configure do
            option :min_time

            def time_range
              min_time...Time.current
            end
          end

          required(:start_at).filled(:time?, included_in?: time_range)
     end

but i have the error when use this schema

CreateSchema.with(min_time: 10.minutes.ago).call(params)

Failure/Error: min_time...Time.current

ArgumentError:
  bad value for range

I think this error raised when schema compiled and option min_time at thid moment is nil. It’s right way to define schema like this with dynamic agruments?

Gustavo Caso
@GustavoCaso
Mar 22 2018 10:29
I think the error comes from min...Time.current
11...Time.current
ArgumentError: bad value for range
Gustavo Caso
@GustavoCaso
Mar 22 2018 10:38
Ups sorry my fault
Semyon Pupkov
@artofhuman
Mar 22 2018 11:19
I use custom validation block =) thanks
Gustavo Caso
@GustavoCaso
Mar 22 2018 11:20
I wish I was a better help :smile: