Where is the documentation for "validargs"?

I was reading the documentation for Functions and found this

https://docs.julialang.org/en/v1.0/manual/functions/#man-functions-1

Optional Arguments

function Date(y::Int64, m::Int64=1, d::Int64=1)
    err = validargs(Date, y, m, d)
    err === nothing || throw(err)
    return Date(UTD(totaldays(y, m, d)))
end

But I can’t find any further information about the validargs function.

Seems like that code example snippet could be simplified to remove some of the unrelated content there. Something like:

function Date(y::Int64, m::Int64=1, d::Int64=1)
    return Date(ymd_to_utd(y, m, d))
end

But what is the function “validargs”?

validargs does not exist. It is just used for the example. As Jameson points out, it is not even relevant and can be safely ignored.

It does, it just isn’t exported.

julia> Dates.validargs
validargs (generic function with 3 methods)
help?> Dates.validargs
  validargs(::Type{<:TimeType}, args...) -> Union{ArgumentError, Nothing}

  Determine whether the given arguments consitute valid inputs for the given type. Returns either an ArgumentError, or nothing in case of success.

But this is incidental, the example just demonstrates optional arguments, and the line checking them could be removed.

4 Likes

Thanks for clarifying, I should have grepped through the codebase before I made that claim. Next time :grin:

1 Like