fastify / fluent-json-schema

A fluent API to generate JSON schemas
MIT License
495 stars 58 forks source link

Nullable false not working #215

Closed conduongtong closed 1 year ago

conduongtong commented 1 year ago

Prerequisites

Fastify version

4.9.2

Plugin version

4.1.0

Node.js version

18.5.0

Operating system

Windows

Operating system version (i.e. 20.04, 11.3, 10)

10

Description

I tried to not allow null in string but it's not working: How can I not allow null, even string array like this: [null]

Steps to Reproduce

Code that I tested not working

S.string()
S.string().raw({nullable: true})
S.string().not(S.null())

Workaround:

S.ifThenElse(S.null(), S.not(S.null()), S.string())

Expected Behavior

No response

Eomm commented 1 year ago

Could you add a Minimal, Reproducible Example?

Without it, we are unable to help you.

This module generates json schema, so that code generates:

{$schema: "http://json-schema.org/draft-07/schema#", type: "string", nullable: true}

https://runkit.com/embed/wdwudrwu14aa