Skip to main content

normalize

$normalize

Normalize the incoming value according using the provided schema

Parameters

  • schema (CompiledSchema, required): the compiled schema to apply to the input value. Any Schema found in a handler pipeline will be automatically compiled; Use $compile to produce a CompiledSchema from a Schema literal value.

Example

import { Schema, SchemaResolver } from '@versionzero/schema';

const resolver = new SchemaResolver();

const = await resolver.compile(
new Schema('object')
.property('collection', new Schema('array')
.property('*', new Schema('string').normalizer('$trim').normalizer('$lowercase'))
.property('chosen', new Schema('string').normalizer({$normalize: {'$find-schema': '^.collection.*'}})
);