Schema Metadata
Metadata is not directly used by the schema itself, but allows external tools (or the schema processors!) to access extra information. Unlike the set of options which are for schema internal use and should only be extended if extending the schema system itself, metadata is an open collection that can be freely assigned.
The Schema fluent builder API uses .meta to set individual items in the .metadata collection.
new Schema('object')
.property('username', new Schema('string')
.meta('flagHint', 'U')
.meta('description', 'username (alphanumeric string)')
.validator({$alphanum})
.validator({$length: {min: 3}})
)
.property('password', new Schema('string')
.meta('secret')
.meta('flagHint', 'P')
.meta('description', '8+ chars, including 1+ each uppercase, lowercase, and special')
.validator({$matches: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/})
.serializer('******')
)
Compiled metadata values are always strings, so metadata checks for boolean values must
interpret truthiness to avoid interpreting "false" strings as boolean true.
See the CompiledSchema API docs for details on accessing the metadata member.
The $metadata value processor can be used to reference metadata from within the processing flow.
The Configurator project leverages Schema metadata extensively to customize CLI argument parsing and help text generation.