Skip to main content
Version: v2

Trim

Trims a string attribute value:

import { trim } from 'dynamodb-toolbox/transformers/trim'

const prefixedSchema = string().transform(trim())

prefixer.encode(' foo ') // => 'foo'
// πŸ‘‡ Does not re-inject the trimmed whitespaces
prefixer.decode('foo') // => 'foo'
// πŸ‘‡ Does not trim when decoding
prefixer.decode(' bar ') // => ' bar '

You can pipe a string transformer with the .pipe(...) method:

import { suffix } from 'dynamodb-toolbox/transformers/suffix'

const piped = trim().pipe(suffix('SUFFIX'))
const schema = string().transform(piped)