Skip to content

date-time regex allows timezone offset to be missing #1031

@bredelman

Description

@bredelman

I'm using this library in tandem with oapi codegen. I am validating a request with ?start_time\=2024-10-22T00:00:00-04:00 as a query param. The validation works fine but I was experimenting and removed the timezone offset and sent ?start_time\=2024-10-22T00:00:00 and that seems to make it past the validation from kin openapi and doesn't make it past the codegen generated validation for date-time.

In their library they do

// Time is a special case of a struct that we handle
			parsedTime, err := time.Parse(time.RFC3339Nano, src)
			if err != nil {
				parsedTime, err = time.Parse(types.DateFormat, src)
				if err != nil {
					return fmt.Errorf("error parsing '%s' as RFC3339 or 2006-01-02 time: %s", src, err)
				}
			}

time.Parse, so if I'm understanding this right, I think the regex needs to be strengthened to match that validation

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions