Giter Club home page Giter Club logo

Comments (3)

climba03003 avatar climba03003 commented on August 11, 2024 1

I would like to close this issue (no privilege for me) because we do not support the type that is not JSON Schema.

Type.RegExp return type: 'RegExp' instead of type: 'string'.
https://github.com/sinclairzx81/typebox/blob/master/src/type/regexp/regexp.ts#L55

cc @sinclairzx81 It there any reason to use RegExp instead of string?

from env-schema.

sinclairzx81 avatar sinclairzx81 commented on August 11, 2024 1

@climba03003 Hi,

This was updated in 0.32.0 with the RegExp type moved to the [JavaScript] type set to draw greater distinction between the regular expressions supported by Json Schema, and expressions supported by the full ECMA 262 syntax. The subset syntax supported by Json Schema (and Ajv) can be found here

The general recommendation is to use Type.String({ pattern: '...' }) to ensure compliance with the specification moving forward. However the RegExp type does enable full support of the full ECMA 262 syntax, including UTF-16 (Unicode) and flags at a cost of being "non-standard". As such, it only works with the TypeBox Value and TypeCompiler modules.

// The following expression cannot be encoded in Json Schema
const E = Type.RegExp(/<a?:.+?:\d{18}>|\p{Extended_Pictographic}/gu)

Value.Check(E, '♥️♦️♠️♣️') // true

Type.RegExp does enable international character set support options for users. But do still recommend Type.String({ pattern: '...' }) for most cases. For Ajv users, the above can be largely expressed via custom string format.

Hope this helps!
S

from env-schema.

Sufiane avatar Sufiane commented on August 11, 2024

@climba03003 you're right we can close this issue.
At first I thought it was related to how fastify-env would interprete the ajv schema.

My bad on this one.

And thanks @sinclairzx81 for the clarification :)

from env-schema.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.