Repository F# setup
open Reified
open Reified.Refinements
open Reified.ResultThe key catalogue
Every built-in key Reified can produce is listed beside the Catalogue API reference:
the key, its arguments, which argument pluralizes, and its default English. Constraint.customLocalized and
customLocalizedWith name your own catalogue entries, which no table can enumerate.
The same data is available at runtime, so a coverage test never has to copy the table:
let keys : string list = Catalogue.keys
let arguments : Map<string, string list> = Catalogue.arguments
let english : Map<string, string> = Catalogue.english
let pluralArgument : Map<string, string option> = Catalogue.pluralArgument
keys: string liststringAn abbreviation for the CLI type . Basic Types
listThe type of immutable singly-linked lists. See the module for further operations related to lists. Use the constructors [] and :: (infix) to create values of this type, or the notation [1; 2; 3]. Use the values in the List module to manipulate values of this type, or pattern match against the values directly. See also F# Language Guide - Lists.
Reified.CatalogueThe built-in message catalogue, and what a translator must cover. Entries are bare predicates: "must be at least {expected}", not a whole sentence. The attribute noun and the optional actual-value clause are separate composition entries (constraint.fullMessage and constraint.actual), so a locale can place either in its own order and {actual} needs no optional-placeholder rule. The composition and joining entries — constraint.attribute.default, constraint.actual, constraint.fullMessage, constraint.group.all.*, constraint.group.any.*, and constraint.list.* — are listed here too, because a language that reorders them must be able to find them.
keys: string listEvery message key Reified can produce, including the composition and joining entries. Enumerate this to test that a translation covers the base catalogue. Catalogue.keys |> List.filter (fun key -> not (translations.ContainsKey key))
arguments: Map<string,string list>Microsoft.FSharp.Collections.FSharpMap`2Immutable maps based on binary trees, where keys are ordered by F# generic comparison. By default comparison is the F# structural comparison function or uses implementations of the IComparable interface on key values. See the module for further operations on maps. All members of this class are thread-safe and may be used concurrently from multiple threads.
arguments: Map<string,string list>The argument names each entry's template may interpolate. actual is not listed: it never appears in a predicate. It reaches a message through the separate constraint.actual composition entry, which is what keeps it optional without an optional-placeholder rule. Catalogue.arguments.["constraint.cardinality.between"] // [ "minimum"; "maximum" ]
english: Map<string,string>english: Map<string,string>The neutral English template for each entry, used when no resource resolves. Catalogue.english.["constraint.presence.present"] // "must be present"
pluralArgument: Map<string,string option>optionThe type of optional values. When used from other CLI languages the empty option is the null value. Use the constructors Some and None to create values of this type. Use the values in the Option module to manipulate values of this type, or pattern match against the values directly. 'None' values will appear as the value null to other CLI languages. Instance methods on this type will appear as static methods to other CLI languages due to the use of null as a value representation. Options
pluralArgument: Map<string,string option>The argument each entry may be pluralized on, when it declares one. At most one per entry. A translation may supply <key>.one and <key>.other for these; every other entry takes a single form. Catalogue.pluralArgument.["constraint.cardinality.minimum"] // Some "minimum"
Requires & types
Requires: open Reified (packages: Reified.Constraint)val keys: string listval arguments: Map<string,string list>val english: Map<string,string>val pluralArgument: Map<string,string option>A test enumerates the atom union against both the reference page and Catalogue, so a new rule cannot ship with its
key undocumented or unimplemented.
Arguments are ConstraintValue, the closed value model every interpreter understands: text, char, boolean, integer,
decimal, big integer, float, GUID, timespan, date-time, date-time-offset, null, and lists of those.
ConstraintValue.render gives the invariant rendering of one; a renderer formats through its value culture instead.