# Enums and string-format validation boundaries

> Run positive and negative compact-schema checks for enums, Color, Base64, Zip, Icon, JSON and IP formats.

Framework: total5
Product: Total.js 5 (total5@0.0.19)
Language: en
Content-SHA256: 7170c1adf5f76b4f2a6754b93b35b731172e178c0fabc248d6e3043eadc8a83c
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: total5-installed@total5@0.0.19
Review: not-recorded

Compact enums use `status:{draft|published}` (semicolon also separates choices). The string is trimmed before exact, case-sensitive membership checking. A required enum rejects an omitted/empty value. Nested objects use `{name:Type}`; they are not enum declarations.

In `total5@0.0.19`, `Color` accepts hexadecimal `#RGB`, `#RRGGBB` and `#RRGGBBAA`; it does not accept CSS color names. `Icon` validates a class-name pattern, not the presence of the icon asset. `Base64` and `Zip` use the framework's validators: format acceptance is not content verification. In the compact-schema parser of this version, **`JSON` and `IP` are not recognized subtypes and fall back to plain strings**. Malformed JSON and invalid IP text are accepted. The explicit JSON Schema below sets native `subtype` values to enable these checks; it does not parse a JSON string into an object. Do not use `SafeString` in place of bound SQL parameters or output escaping.

```js controllers/formats.js
var schema = NEWSCHEMA('FormatBoundaries', '*status:{draft|published},*color:Color,*blob:Base64,*zip:Zip,*icon:Icon,*document:JSON,*address:IP');
var explicit = Total.newjsonschema('ExplicitFormats', { $id: 'ExplicitFormats', type: 'object', required: ['document','address'], properties: { document: { type: 'string', subtype: 'json' }, address: { type: 'string', subtype: 'ip' } } });
exports.install = function() {
	ROUTE('POST /explicit/ @json', function($) {
		var result = explicit.transform($.body);
		if (result.error) { $.response.status = 400; $.json({ error: 'invalid format' }); }
		else $.json(result.response);
	});
	ROUTE('POST /formats/ @json', formats);
};
function formats($) {
	var result = schema.transform($.body);
	if (result.error) {
		$.response.status = 400;
		$.json({ error: 'invalid format' });
	} else
		$.json(result.response);
}
```
