elixir-maru / maru

Elixir RESTful Framework
https://maru.readme.io
BSD 3-Clause "New" or "Revised" License
1.32k stars 85 forks source link

Pass param options as second argument to ParamType #21

Closed venkatd closed 8 years ago

venkatd commented 8 years ago

Right now I implement a param type like so:

defmodule Maru.ParamType.Time do
  def from(string) do
    case Timex.parse(string, "{ISO:Extended}") do
      {:ok, time} ->
        time
      {:error, _} ->
        raise Turtle.API.InvalidParamException, error: "Invalid time #{string}. Expected ISO8601 like 2016-04-21T22:26:01Z"
    end
  end
end

Two things

I think if the 2nd argument got all of the options it would solve this.

What do you think of this? Thanks!

falood commented 8 years ago

As our last talk via #20, the second point is OK. But I can't get your point about second argument. What do you define allow_formats: ["m/d/Y"] for? Could you show me more details or examples?

falood commented 8 years ago

This feature has been achieved at master version, and here is the document. Will this resolve your problem? Feel free to give me any suggestion, please.

venkatd commented 8 years ago

Thanks @falood this will do the trick. I will upgrade and get back to you with any suggestions.

falood commented 8 years ago

maru v0.10.0 is out :D