Below is an attempt to provide a comprehensive reference table for Malli's built-in schemas, detailing their purpose, supported options, and usage examples. Note that this is based solely on the codebase you provided, so it may not represent the full capabilities of the library.
Schema Key | Explanation | Supported Options | Usage Examples |
---|---|---|---|
:any |
Matches any value. | None | [:any] - A schema that accepts any value. |
:some |
Matches any non-nil value. | None | [:some] - A schema that accepts any value except nil. |
:nil |
Matches only the value nil . |
None | [:nil] - A schema that accepts only nil. |
:string |
Matches strings. | :min , :max (string length) |
[:string] - Any string. [:string {:min 1, :max 10}] - A string with length between 1 and 10. |
:int |
Matches integers. | :min , :max |
[:int] - Any integer. [:int {:min 0}] - A non-negative integer. |
:float |
Matches floating point numbers. | :min , :max , :gen/infinite? , :gen/NaN? |
[:float] - Any float. [:float {:min 0.0}] - A non-negative float. |
:double |
Matches double-precision floating point numbers. | :min , :max , :gen/infinite? , :gen/NaN? |
[:double] - Any double. [:double {:min 0.0}] - A non-negative double. |
:boolean |
Matches boolean values (true or false ). |
None | [:boolean] - A schema that accepts only true or false. |
:keyword |
Matches keywords. | None | [:keyword] - A schema that accepts any keyword. |
:qualified-keyword |
Matches qualified keywords (keywords with a namespace). | :namespace |
[:qualified-keyword] - Any qualified keyword. [:qualified-keyword {:namespace :my-ns}] - Keywords in the my-ns namespace. |
:symbol |
Matches symbols. | None | [:symbol] - A schema that accepts any symbol. |
:qualified-symbol |
Matches qualified symbols (symbols with a namespace). | :namespace |
[:qualified-symbol] - Any qualified symbol. [:qualified-symbol {:namespace :my-ns}] - Symbols in the my-ns namespace. |
:uuid |
Matches UUIDs. | None | [:uuid] - A schema that accepts any UUID. |
:> |
Matches numbers greater than a specified value. | None (Value to compare against is the child schema). | [:> 10] - A number greater than 10. |
:>= |
Matches numbers greater than or equal to a specified value. | None (Value to compare against is the child schema). | [:>= 10] - A number greater than or equal to 10. |
:< |
Matches numbers less than a specified value. | None (Value to compare against is the child schema). | [:< 10] - A number less than 10. |
:<= |
Matches numbers less than or equal to a specified value. | None (Value to compare against is the child schema). | [:<= 10] - A number less than or equal to 10. |
:= |
Matches a specific value. | None (Value to match is the child schema). | [:= "hello"] - Matches only the string "hello". [:= 42] - Matches only the integer 42. |
:not= |
Matches any value except a specific value. | None (Value to exclude is the child schema). | [:not= "hello"] - Matches any value except the string "hello". [:not= 42] - Matches any value except the integer 42. |
:not |
Matches if the child schema does not match. | None | [:not :int] - Matches anything that is not an integer. |
:and |
Matches if all child schemas match. | None | [:and :int [:> 0]] - Matches any positive integer. |
:or |
Matches if at least one child schema matches. | None | [:or :int :string] - Matches either an integer or a string. |
:orn |
Matches if at least one child schema matches, with names for each branch. | None | [:orn [:a :int] [:b :string]] - Matches either an integer (:a) or a string (:b). Used with tagged values from parsing/unparsing. |
:map |
Matches maps (associative data structures). | :closed (boolean, whether the map can contain keys not defined in the schema) |
[:map [:name :string] [:age :int]] - A map with keys :name (string) and :age (int). [:map {:closed true} [:name :string]] - Map that can only contain name |
:map-of |
Matches maps with homogenous key-value types. | :minProperties , :maxProperties (number of key-value pairs). |
[:map-of :string :int] - A map where keys are strings and values are integers. |
:vector |
Matches vectors (ordered collections). | :min , :max (number of elements) |
[:vector :int] - A vector of integers. [:vector {:min 1, :max 10} :string] - A vector with 1-10 strings. |
:sequential |
Matches sequential collections (lists, vectors, etc.). | :min , :max (number of elements) |
[:sequential :int] - A sequential collection of integers. |
:set |
Matches sets (unordered collections with unique elements). | :min , :max (number of elements), :uniqueItems (boolean, default true ) |
[:set :keyword] - A set of keywords. [:set {:min 1} :string] - Set that has a minimum of 1 element |
:enum |
Matches one of specified values. | None (The specified values are the schema; no additional options). | [:enum "a" "b" "c"] - Matches the strings "a", "b", or "c". [:enum 1 2 3] - Matches the integers 1, 2, or 3. |
:maybe |
Matches either the child schema or nil . |
None | [:maybe :string] - Matches either a string or nil . |
:tuple |
Matches fixed-length vectors with specific element schemas. | None | [:tuple :string :int :boolean] - A tuple with a string, an int, and a boolean, in that order. |
:re |
Matches strings against a regular expression. | None (The regular expression is the child schema). | [:re #"^[a-zA-Z]+$"] - Matches a string containing only letters. |
:fn |
Matches if a function returns true for the value. | None (The function is the child schema). | [:fn #(> % 0)] - Matches numbers greater than zero. |
:=> (Function Schema) |
Matches a function with specific input and output schemas. | None (input and output schemas are children) | [:=> [:cat :int :int] :int] - A function that takes two integers and returns an integer. Used for specifying schemas for function arguments and return types. |
:function (Function Schema) |
Matches a multi-arity function with specific input and output schemas. | None (child schemas are => schemas) | [:function [:=> [:cat :int] :int] [:=> [:cat :int :int] :int]] - A function that takes either one or two integers and returns an integer. |
:schema |
Refers to another schema within a registry. | :registry (local registry), :lazy-refs (boolean, makes schema lazy), :raw (boolean, uses type as form) |
[:schema :my/schema] - Refers to the schema with key :my/schema in the registry. |
Notes:
::m/default
is not a type, but a key in a map schema that allows specifying a default schema for keys not explicitly listed.- "":"" indicates "private" helper keys in code.
- "EXPERIMENTAL" time schema (see documentation).
- The listing has been generated automatically from the code using an AI and manual edits were made.
- Function Schemas can have the following keys in metadata:
:malli/schema
,:malli/scope
,:malli/report
,:malli/gen
This table is a best-effort attempt to document the Malli library based on the provided code. For the most up-to-date information, always refer to the official Malli documentation and source code.