• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

gavinwahl/postgres-json-schema: JSON Schema validation for PostgreSQL

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

gavinwahl/postgres-json-schema

开源软件地址:

https://github.com/gavinwahl/postgres-json-schema

开源编程语言:

PLpgSQL 87.0%

开源软件介绍:

postgres-json-schema

Build Status

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

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

Installation

postgres-json-schema is packaged as an PGXS extension. To install, just run make install as root, then CREATE EXTENSION "postgres-json-schema"; as the database 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 1

INSERT INTO example (data) VALUES ('1');
-- ERROR:  new row for relation "example" violates check constraint "data_is_valid"
-- DETAIL:  Failing row contains (2, 1).



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap