Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

JSON Schema validation for PostgreSQL

License

NotificationsYou must be signed in to change notification settings

gavinwahl/postgres-json-schema

Repository files navigation

Build Status

postgres-json-schema allows validation ofJSONschemas in PostgreSQL. It is implemented as aPL/pgSQL function and you can use it as a check constraint to validate theformat of your JSON columns.

postgres-json-schema supports the entire JSON schema draft v4 spec, except forremote (http) references. It's tested against the officialJSON-Schema-Test-Suite.

Installation

postgres-json-schema is packaged as an PGXS extension. To install, just runmake install as root, thenCREATE EXTENSION "postgres-json-schema"; as thedatabase superuser.

Example

CREATE TABLE example (id serial PRIMARY KEY, data jsonb);ALTER TABLE example ADD CONSTRAINT data_is_valid CHECK (validate_json_schema('{"type": "object"}', data));INSERT INTO example (data) VALUES ('{}');-- INSERT 0 1INSERT INTO example (data) VALUES ('1');-- ERROR:  new row for relation "example" violates check constraint "data_is_valid"-- DETAIL:  Failing row contains (2, 1).

About

JSON Schema validation for PostgreSQL

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors3

  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp