Validate Library: Receiving error for nil with required: false

I am receiving errors even the the required is set as false. Below are the params & the rules. Anybody who has worked with this. What am I doing wrong?

Params:

%{"tags" => ["tag1", "tag2"]}

Rules:

%{
  "referral_url_query" => [required: false, type: :string],
  "referred_by" => [required: false, type: :uuid],
  "status" => [
    required: false,
    type: :string,
    in: ["approved", "banned", "pending"]
  ],
  "tags" => [
    required: false,
    type: :list,
    list: [required: false, type: :string]
  ]
}

Errors:

[
  referral_url_query: {"expected string received nil", [rule: :type]}, 
  status: {"expected string received nil", [rule: :type]}
]

I have never used the lib myself, but checked the issues, and this talks about something similar.
Maybe try adding nullable: true before type: :string and see what that does.

1 Like

Thanks! Yes that was the solution. I got confused coz having to set nullable along with required: false kind of feels like an antipattern.