1.0.7 • Published 2 days ago

@schemasjs/valibot-numbers v1.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
2 days ago

@SchemasJS/valibot-numbers

build

Valibot schemas for numbers and their types.

Numbers

DataSchemaTypeValues
Unsigned integers
Unsigned integer 8 bitsUint8SchemaUint80 to 255
Unsigned integer 16 bitsUint16SchemaUint160 to 65535
Unsigned integer 32 bitsUint32SchemaUint320 to 4294967295
Unsigned Big IntegerBigUintSchemaBigUint0 to 2^64-1
Integers
Integer 8 bitsInt8SchemaInt8-128 to 127
Integer 16 bitsInt16SchemaInt16-32768 to 32767
Integer 32 bitsInt32SchemaInt32-2147483648 to 2147483647
Big IntegerBigIntSchemabuilt-in TS-2^63 to 2^63-1
Floats
Float 32 bitFloat32SchemaFloat32-3.4e38 to 3.4e38
Float 64 bitFloat64SchemaFloat64-1.8e308 to 1.8e308

Typed Arrays

It contains typed arrays too.

DataSchemaTypeValues
Unsigned integers
Unsigned integer 8 bitsUint8ArraySchemabuilt-in TS0 to 255
Unsigned integer 16 bitsUint16ArraySchemabuilt-in TS0 to 65535
Unsigned integer 32 bitsUint32ArraySchemabuilt-in TS0 to 4294967295
Unsigned Big IntegerBigUint64ArraySchemabuilt-in TS0 to 2^64-1
Integers
Integer 8 bitsInt8ArraySchemabuilt-in TS-128 to 127
Integer 16 bitsInt16ArraySchemabuilt-in TS-32768 to 32767
Integer 32 bitsInt32ArraySchemabuilt-in TS-2147483648 to 2147483647
Big IntegerBigInt64ArraySchemabuilt-in TS-2^63 to 2^63-1
Floats
Float 32 bitFloat32ArraySchemabuilt-in TS-3.4e38 to 3.4e38
Float 64 bitFloat64ArraySchemabuilt-in TS-1.8e308 to 1.8e308

There is a cool feature: It is added if you introduce a number, it could be transformed into an typed array. For example:

import * as v from 'valibot'
import { Uint8ArraTransform, Uint16ArrayTransform } from @schemasjs/valibot-numbers

const num = 256

console.log(v.parse(Uint8ArrayTransform, num)) // [255, 1]
console.log(v.parse(Uint16ArrayTransform, num)) // [256]
DataSchemaTypeValues
Unsigned integers
Unsigned integer 8 bitsUint8ArrayTransformbuilt-in TS0 to 255
Unsigned integer 16 bitsUint16ArrayTransformbuilt-in TS0 to 65535
Unsigned integer 32 bitsUint32ArrayTransformbuilt-in TS0 to 4294967295
Unsigned Big IntegerBigUint64ArrayTransformbuilt-in TS0 to 2^64-1
Integers
Integer 8 bitsInt8ArrayTransformbuilt-in TS-128 to 127
Integer 16 bitsInt16ArrayTransformbuilt-in TS-32768 to 32767
Integer 32 bitsInt32ArrayTransformbuilt-in TS-2147483648 to 2147483647
Big IntegerBigInt64ArrayTransformbuilt-in TS-2^63 to 2^63-1
Floats
Float 32 bitFloat32ArrayTransformbuilt-in TS-3.4e38 to 3.4e38
Float 64 bitFloat64ArrayTransformbuilt-in TS-1.8e308 to 1.8e308
1.0.7

2 days ago

1.0.5

2 months ago

1.0.4

2 months ago

1.0.3

2 months ago

1.0.0

3 months ago

0.0.6

3 months ago

0.0.5

3 months ago

0.0.4

3 months ago

0.0.3

3 months ago

0.0.2

3 months ago

0.0.1

3 months ago