Skip to content

Commit

Permalink
Format README
Browse files Browse the repository at this point in the history
  • Loading branch information
reilem committed Feb 23, 2024
1 parent 7bee396 commit e27d694
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This repository contains GeoJSON schemas for the [Zod](https://github.com/colinhacks/zod) validation library.

The schemas are based on the GeoJSON specification found in this RFC: https://datatracker.ietf.org/doc/html/rfc7946. The
The schemas are based on the GeoJSON specification found in this RFC: https://datatracker.ietf.org/doc/html/rfc7946. The
schemas do not only validate the basic structure of the GeoJSON objects but also the validity of the geometries and
bounding boxes.

Expand All @@ -24,17 +24,17 @@ pnpm add zod-geojson
Then you can use the schemas in your code:

```typescript
import { GeoJSONSchema } from 'zod-geojson';
import { GeoJSONSchema } from "zod-geojson";

const schema = GeoJSONSchema.parse({
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [0, 0],
},
properties: {
name: 'Null Island',
},
type: "Feature",
geometry: {
type: "Point",
coordinates: [0, 0],
},
properties: {
name: "Null Island",
},
});
```

Expand All @@ -52,7 +52,7 @@ import {
GeoJSONPolygonSchema,
GeoJSONLineStringSchema,
GeoJSONPointSchema,
} from 'zod-geojson';
} from "zod-geojson";
```

It also exposes the resulting types from the schemas:
Expand All @@ -69,7 +69,7 @@ import type {
GeoJSONPolygon,
GeoJSONLineString,
GeoJSONPoint,
} from 'zod-geojson';
} from "zod-geojson";
```

## Error Cases
Expand All @@ -78,22 +78,21 @@ This library will throw an error if the GeoJSON object is not valid. For example
not match the geometry type:

```typescript
import { GeoJSONSchema } from 'zod-geojson';
import { GeoJSONSchema } from "zod-geojson";

const schema = GeoJSONSchema.parse({
type: 'Point',
type: "Point",
coordinates: [[0, 0]],
});

```

It will also throw an error if the bounding box does not match the geometry:

```typescript
import { GeoJSONSchema } from 'zod-geojson';
import { GeoJSONSchema } from "zod-geojson";

const schema = GeoJSONSchema.parse({
type: 'MultiPoint',
type: "MultiPoint",
coordinates: [
[-2, 0],
[3, 4],
Expand All @@ -105,4 +104,4 @@ const schema = GeoJSONSchema.parse({

## Contributing

If you find any issues with the schemas or want to add new features, feel free to open an issue or a pull request.
If you find any issues with the schemas or want to add new features, feel free to open an issue or a pull request.

0 comments on commit e27d694

Please sign in to comment.