From 0151eb538680a49fe2ca6f5bbd9a1d037d89b8f1 Mon Sep 17 00:00:00 2001 From: HeNine <> Date: Sun, 29 Jan 2023 09:42:19 +0100 Subject: [PATCH] add custom type library --- lib/entity.libsonnet | 14 +++----------- lib/types.libsonnet | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 11 deletions(-) create mode 100644 lib/types.libsonnet diff --git a/lib/entity.libsonnet b/lib/entity.libsonnet index eb610af..d8f7723 100644 --- a/lib/entity.libsonnet +++ b/lib/entity.libsonnet @@ -1,3 +1,5 @@ +local types = import "types.libsonnet"; + { '$id': 'https://picc.app/schemata/v0.1-dev/entity', '$schema': 'http://json-schema.org/draft-07/schema', @@ -9,17 +11,7 @@ |||, type: 'object', properties: { - id: { - description: ||| - Identifier that is unique within a server. - - It consists of a string of numbers, upper and/or lower case letters, and special cheracters `-` and `_`. - |||, - type: 'string', - minLength: 1, - maxLength: 50, - pattern: '^[0-9a-zA-Z-_]+$', - }, + id: types.id, name: { type: 'string', description: ||| diff --git a/lib/types.libsonnet b/lib/types.libsonnet new file mode 100644 index 0000000..279210a --- /dev/null +++ b/lib/types.libsonnet @@ -0,0 +1,39 @@ +{ + id: { + description: ||| + Identifier that is unique within a server. + + It consists of a string of numbers, upper and/or lower case letters, and special cheracter `-`. + |||, + type: 'string', + minLength: 1, + maxLength: 50, + pattern: '^[0-9a-zA-Z-]+$', + }, + + location: { + description: ||| + Coordinates of a specific location in the WGS 84 datum. + |||, + type: 'object', + properties: { + latitude: { + type: 'number', + description: "Latitude", + minimum: -90, + maximum: 90, + }, + longitude: { + type: 'number', + description: "Longitude", + minimum: -180, + maximum: 180, + }, + altitude: { + description: "Altitude", + type: 'number', + }, + }, + required: ["latitude", "longitude", "altitude"] + }, +}