Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion api/generated/oas_json_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 39 additions & 8 deletions api/generated/oas_schemas_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions api/generated/oas_validators_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 15 additions & 5 deletions api/openapi/components/flows/field.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ description: |
properties:
type:
type: string
enum: [text, email, password, tel, number, url, date, hidden]
enum: [text, email, password, tel, number, url, date, hidden, checkbox, select]
description: |
The input kind the client should render. Encodes the formats that
have a matching HTML input type (email, url, date). For other
formats (e.g. uuid) the type is `text` and `validation.format`
carries the rule.
The input kind the client should render. Encodes the formats and
JSON types that map to a familiar HTML input: `email`, `url`,
`date` come from `format`; `checkbox` from JSON `type: boolean`;
`select` from a closed `enum`. For other formats (e.g. uuid) the
type is `text` and `validation.format` carries the rule.
text_key:
type: string
description: Localization key for the field label.
Expand Down Expand Up @@ -53,3 +54,12 @@ properties:
type: integer
minimum: 0
description: Maximum length in characters (inclusive). Mirrors `maxLength`.
enum:
type: array
items:
type: string
description: |
Closed list of allowed values. Mirrors the JSON Schema `enum`
keyword on the underlying user property. When `type` is
`select` the client renders these as options; for other types
the rule still applies as a membership check.
11 changes: 11 additions & 0 deletions internal/domain/flow_field_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,15 @@ const (
// - Format ↔ `format` (enum: email, date-time, uuid, uri)
// - MinLength ↔ `minLength`
// - MaxLength ↔ `maxLength`
// - Enum ↔ `enum` (closed set of allowed string values)
//
// Zero values mean "no rule". JSON Schema's `pattern` keyword is not
// part of the user meta-schema and is intentionally not surfaced.
type FlowFieldValidation struct {
Format string
MinLength int
MaxLength int
Enum []string
Comment thread
vitorbari marked this conversation as resolved.
}

// FlowFieldType names the input kind the client should render. Mirrors
Expand All @@ -137,6 +139,8 @@ const (
FlowFieldTypeURL FlowFieldType = "url"
FlowFieldTypeDate FlowFieldType = "date"
FlowFieldTypeHidden FlowFieldType = "hidden"
FlowFieldTypeCheckbox FlowFieldType = "checkbox"
FlowFieldTypeSelect FlowFieldType = "select"
)

// FlowFieldValidationRule names a schema-derived validation rule the
Expand Down Expand Up @@ -200,3 +204,10 @@ func ImplicitOutcomesForChallenge(c FlowFieldChallenge) []string {
// ErrFlowFieldUnknown is returned by [FlowFieldResolver.Resolve] when a
// requested field name is not part of the resolver's schema or catalog.
var ErrFlowFieldUnknown = errors.New("flow field: not in resolver catalog")

// ErrFlowFieldUnsupportedType is returned by [FlowFieldResolver.Resolve]
// when a property declares a JSON `type` set the resolver cannot
// reduce to a single input kind. The nullable idiom `["null", X]` is
// reduced to X and does not trigger this error; any other multi-entry
// union does.
var ErrFlowFieldUnsupportedType = errors.New("flow field: unsupported JSON type")
Loading
Loading