Skip to content
Merged
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
52 changes: 50 additions & 2 deletions lib/schemas.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ defmodule ValueFormatters.Schemas do
description: "Number of decimal places"
},
unit: %{
type: :string,
type: [:string, :null],
description: "If set, the formatter appends ' ' + unit to the display value"
}
}
Expand Down Expand Up @@ -84,7 +84,7 @@ defmodule ValueFormatters.Schemas.Format do
description: "Formats for value formatting",
oneOf: [
%{
const: nil,
type: :null,
description: "Skip formatting and return raw value."
},
%{
Expand All @@ -109,6 +109,11 @@ defmodule ValueFormatters.Schemas.Format do
const: "string",
description:
"Use to explicitly disable any kind of formatting that would otherwise take place, but still return a string."
},
field: %{
type: :string,
description:
"If the value is an object, the field to extract the formattable entity from."
}
},
required: [:format],
Expand All @@ -124,6 +129,11 @@ defmodule ValueFormatters.Schemas.Format do
const: "number",
description:
"Use to display numeric values and format them according to the user's locale."
},
field: %{
type: :string,
description:
"If the value is an object, the field to extract the formattable entity from."
}
},
number_options()
Expand All @@ -141,6 +151,11 @@ defmodule ValueFormatters.Schemas.Format do
const: "date",
description:
"Use to display date-time values and format them according to the user's locale."
},
field: %{
type: :string,
description:
"If the value is an object, the field to extract the formattable entity from."
}
},
date_options()
Expand All @@ -161,6 +176,11 @@ defmodule ValueFormatters.Schemas.Format do

This format currently doesn't support any options.
"""
},
field: %{
type: :string,
description:
"If the value is an object, the field to extract the formattable entity from."
}
},
required: [:format],
Expand All @@ -173,6 +193,11 @@ defmodule ValueFormatters.Schemas.Format do
format: %{
const: "date_iso",
description: "Use to display date-time values in ISO 8601 extended format."
},
field: %{
type: :string,
description:
"If the value is an object, the field to extract the formattable entity from."
}
},
required: [:format],
Expand All @@ -187,6 +212,11 @@ defmodule ValueFormatters.Schemas.Format do
format: %{
const: "date_unix",
description: "Use to display date-time values in seconds since unix epoch."
},
field: %{
type: :string,
description:
"If the value is an object, the field to extract the formattable entity from."
}
},
date_unix_options()
Expand All @@ -203,12 +233,30 @@ defmodule ValueFormatters.Schemas.Format do
format: %{
const: "coordinates",
description: "Use to display latitude & longitude information."
},
field: %{
type: :string,
description:
"If the value is an object, the field to extract the formattable entity from."
}
},
coordinates_options()
),
required: [:format],
additionalProperties: false
},
%{
type: "object",
title: "field",
properties: %{
field: %{
type: :string,
description:
"If the value is an object, the field to extract the formattable entity from."
}
},
required: [:field],
additionalProperties: false
}
]
}
Expand Down
Loading