Skip to content

How to apply a transform function on fluent-json-schema #1034

@bacloud22

Description

@bacloud22

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:

// 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions