Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set a transform function on fluent-json-schema #1050

Closed
bacloud22 opened this issue Aug 22, 2024 · 0 comments
Closed

Set a transform function on fluent-json-schema #1050

bacloud22 opened this issue Aug 22, 2024 · 0 comments
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@bacloud22
Copy link

Hi
I saw there is the option to set transforms as an options like:

const fastify = require("fastify")({
  logger: true,
  ajv: {
    plugins: [[require("ajv-keywords"), "transform"]],
  },
});

So this works along with plain JSON schemas , For me I'm using "fluent-json-schema". Is there a way to add a transform function on fields ?

like:

export const userLoginSchema = S.object()
    .prop('firstName', S.string().minLength(2).maxLength(40)), // .transform() <-- trim and lowercase for example. or even add a custom transformer 
    .prop('username', S.string().format(S.FORMATS.EMAIL))
    .prop('password', S.string().minLength(8).maxLength(40))
    .required(['username', 'password'])

Thanks a lot for your help

@bacloud22 bacloud22 added the help wanted Extra attention is needed label Aug 22, 2024
@dosubot dosubot bot added the question Further information is requested label Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant