@tmlmobilidade/go-types-shared 20260910.1431.8 → 20260910.1808.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/numbers/degrees.d.ts +24 -0
- package/dist/numbers/degrees.js +29 -0
- package/dist/numbers/float.d.ts +1 -0
- package/dist/numbers/index.d.ts +1 -0
- package/dist/numbers/index.js +1 -0
- package/dist/numbers/integer.d.ts +1 -0
- package/dist/numbers/non-negative-float.d.ts +1 -0
- package/dist/numbers/non-negative-integer.d.ts +1 -0
- package/dist/numbers/percent.d.ts +2 -1
- package/dist/numbers/percent.js +2 -1
- package/package.json +1 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* A schema for degrees in the range 0-360,
|
|
4
|
+
* It transforms the value to a number, rounds it
|
|
5
|
+
* to the nearest integer, and ensures it is in the range 0-360.
|
|
6
|
+
* @throws if the value cannot be coerced to a number or if it is not in the range 0-360.
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const schema = DegreesSchema.parse(50);
|
|
10
|
+
* // => 50
|
|
11
|
+
* const schema = DegreesSchema.parse("75");
|
|
12
|
+
* // => 75
|
|
13
|
+
* const schema = DegreesSchema.parse(360);
|
|
14
|
+
* // => 0
|
|
15
|
+
* const schema = DegreesSchema.parse(361);
|
|
16
|
+
* // => throws an error
|
|
17
|
+
* const schema = DegreesSchema.parse(-1);
|
|
18
|
+
* // => throws an error
|
|
19
|
+
* const schema = DegreesSchema.parse("50.1");
|
|
20
|
+
* // => 50
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare const DegreesSchema: z.ZodBranded<z.ZodPipeline<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>, number, string | number>, z.ZodNumber>, "Degrees">;
|
|
24
|
+
export type Degrees = z.infer<typeof DegreesSchema>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/* * */
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* A schema for degrees in the range 0-360,
|
|
5
|
+
* It transforms the value to a number, rounds it
|
|
6
|
+
* to the nearest integer, and ensures it is in the range 0-360.
|
|
7
|
+
* @throws if the value cannot be coerced to a number or if it is not in the range 0-360.
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const schema = DegreesSchema.parse(50);
|
|
11
|
+
* // => 50
|
|
12
|
+
* const schema = DegreesSchema.parse("75");
|
|
13
|
+
* // => 75
|
|
14
|
+
* const schema = DegreesSchema.parse(360);
|
|
15
|
+
* // => 0
|
|
16
|
+
* const schema = DegreesSchema.parse(361);
|
|
17
|
+
* // => throws an error
|
|
18
|
+
* const schema = DegreesSchema.parse(-1);
|
|
19
|
+
* // => throws an error
|
|
20
|
+
* const schema = DegreesSchema.parse("50.1");
|
|
21
|
+
* // => 50
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export const DegreesSchema = z
|
|
25
|
+
.union([z.string(), z.number()])
|
|
26
|
+
.transform(value => Math.round(Number(value)))
|
|
27
|
+
.transform(value => value === 360 ? 0 : value)
|
|
28
|
+
.pipe(z.number().int().min(0).lt(360))
|
|
29
|
+
.brand('Degrees');
|
package/dist/numbers/float.d.ts
CHANGED
package/dist/numbers/index.d.ts
CHANGED
package/dist/numbers/index.js
CHANGED
|
@@ -21,3 +21,4 @@ import { z } from 'zod';
|
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
23
|
export declare const NonNegativeIntegerSchema: z.ZodPipeline<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>, z.ZodNumber>;
|
|
24
|
+
export type NonNegativeInteger = z.infer<typeof NonNegativeIntegerSchema>;
|
|
@@ -18,4 +18,5 @@ import { z } from 'zod';
|
|
|
18
18
|
* // => 50
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
|
-
export declare const PercentSchema: z.ZodPipeline<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>, z.ZodNumber>;
|
|
21
|
+
export declare const PercentSchema: z.ZodBranded<z.ZodPipeline<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>, z.ZodNumber>, "Percent">;
|
|
22
|
+
export type Percent = z.infer<typeof PercentSchema>;
|
package/dist/numbers/percent.js
CHANGED