fastify / fastify/help

How to apply a transform function on `fluent-json-schema`

Open
#1,034 0 comments 0 reactions 0 assignees View on GitHub
enhancement help wanted
Dominant language
No language data
Stars
68
Forks
8
Avg merge
11h 2m
Merged PRs (30d)
2

Description

Hi,
*fluent-json-schema* is used for validation, but I want to add a transformer (trim in my case), that I'm thinking it can go hand in hand with validaiton.

For reference, I looked for answers, and this relates: https://stackoverflow.com/a/63305773

But I'm using `fluent-json-schema` specifically:
```js
// example: How to trim string values here?

import S from 'fluent-json-schema'

export const signupSchema = S.object()
.prop('unique_tab_id', S.string().minLength(36).maxLength(36))
.prop('username', S.string().format(S.FORMATS.EMAIL))
.prop('password', S.string().minLength(4).maxLength(40))
.prop('firstName', S.string().minLength(2).maxLength(40))
.prop('secondName', S.string().minLength(2).maxLength(40))
.required(['username', 'password', 'firstName', 'secondName'])
```
If this is not possible, do you think it is useful to add some transform function for `fluent-json-schema` as an option ?

Kindly

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.