A Claude-written graph database in Rust. Use at your own risk.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Update documentation for schema validation and constraints

- Add comprehensive schema constraints documentation to API.md
* Document all 5 constraint types: required, type, range, pattern, enum
* Include request/response examples for each constraint type
* Add practical examples showing constraint validation in action

- Update README.md to:
* Add schema validation to the features list
* Fix property format in example (use simple key-value instead of nested)

- Update embedded API documentation in rest.rs to include:
* POST /api/v1/constraints endpoint documentation
* GET /api/v1/constraints endpoint documentation
* Example constraint creation request/response

- Add detailed examples showing constraint workflow:
* Creating constraints for Employee nodes
* Demonstrating validation errors
* Successful node creation with constraints

Documentation now accurately reflects the complete schema validation system.

๐Ÿค– Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

+206 -4
+5 -4
README.md
··· 11 11 - **๐Ÿ” Authentication**: JWT-based auth with role-based access control 12 12 - **๐Ÿ’พ Persistence**: Optional RocksDB backend for data durability 13 13 - **๐Ÿ“ˆ Monitoring**: Built-in metrics and observability 14 + - **โœ… Schema Validation**: Comprehensive constraint system for data integrity 14 15 15 16 ## ๐Ÿš€ Quick Start 16 17 ··· 40 41 -H "Content-Type: application/json" \ 41 42 -d '{ 42 43 "labels": ["Person"], 43 - "properties": [ 44 - {"key": "name", "value": {"string_value": "Alice"}}, 45 - {"key": "age", "value": {"int_value": 30}} 46 - ] 44 + "properties": { 45 + "name": "Alice", 46 + "age": 30 47 + } 47 48 }' 48 49 49 50 # Execute Cypher query
+172
docs/API.md
··· 417 417 418 418 Returns this API documentation in JSON format. 419 419 420 + ### Schema Constraints 421 + 422 + #### Create Constraint 423 + 424 + **POST** `/constraints` 425 + 426 + Creates a new schema constraint to enforce data integrity rules. 427 + 428 + **Request Body:** 429 + ```json 430 + { 431 + "constraint_type": "required", 432 + "label": "Employee", 433 + "property": "email" 434 + } 435 + ``` 436 + 437 + **Constraint Types:** 438 + 439 + 1. **Required Constraint** 440 + ```json 441 + { 442 + "constraint_type": "required", 443 + "label": "Employee", 444 + "property": "email" 445 + } 446 + ``` 447 + 448 + 2. **Type Constraint** 449 + ```json 450 + { 451 + "constraint_type": "type", 452 + "label": "Employee", 453 + "property": "salary", 454 + "type_value": "integer" 455 + } 456 + ``` 457 + Supported types: `string`, `integer`, `float`, `boolean` 458 + 459 + 3. **Range Constraint** 460 + ```json 461 + { 462 + "constraint_type": "range", 463 + "label": "Employee", 464 + "property": "salary", 465 + "min_value": 30000, 466 + "max_value": 200000 467 + } 468 + ``` 469 + 470 + 4. **Pattern Constraint** 471 + ```json 472 + { 473 + "constraint_type": "pattern", 474 + "label": "User", 475 + "property": "email", 476 + "pattern": "@" 477 + } 478 + ``` 479 + 480 + 5. **Enum Constraint** 481 + ```json 482 + { 483 + "constraint_type": "enum", 484 + "label": "Task", 485 + "property": "status", 486 + "allowed_values": ["pending", "in_progress", "completed"] 487 + } 488 + ``` 489 + 490 + **Response:** 491 + ```json 492 + { 493 + "id": "required:Employee:email", 494 + "constraint_type": "required", 495 + "label": "Employee", 496 + "property": "email", 497 + "details": {} 498 + } 499 + ``` 500 + 501 + #### List Constraints 502 + 503 + **GET** `/constraints` 504 + 505 + Lists all defined schema constraints. 506 + 507 + **Response:** 508 + ```json 509 + [ 510 + { 511 + "id": "required:Employee:email", 512 + "constraint_type": "required", 513 + "label": "Employee", 514 + "property": "email", 515 + "details": {} 516 + }, 517 + { 518 + "id": "type:Employee:salary", 519 + "constraint_type": "type", 520 + "label": "Employee", 521 + "property": "salary", 522 + "details": { 523 + "type": "Integer" 524 + } 525 + } 526 + ] 527 + ``` 528 + 420 529 ## gRPC API 421 530 422 531 The gRPC API provides the same functionality as the REST API but uses Protocol Buffers for serialization. The service is defined in `proto/gigabrain.proto`. ··· 558 667 # Delete a specific property 559 668 curl -X DELETE http://localhost:3000/api/v1/nodes/1/properties/age \ 560 669 -H "Authorization: Bearer <token>" 670 + ``` 671 + 672 + ### Working with Schema Constraints 673 + 674 + ```bash 675 + # Create a required email constraint for Employee nodes 676 + curl -X POST http://localhost:3000/api/v1/constraints \ 677 + -H "Content-Type: application/json" \ 678 + -H "Authorization: Bearer <token>" \ 679 + -d '{ 680 + "constraint_type": "required", 681 + "label": "Employee", 682 + "property": "email" 683 + }' 684 + 685 + # Create a type constraint for salary 686 + curl -X POST http://localhost:3000/api/v1/constraints \ 687 + -H "Content-Type: application/json" \ 688 + -H "Authorization: Bearer <token>" \ 689 + -d '{ 690 + "constraint_type": "type", 691 + "label": "Employee", 692 + "property": "salary", 693 + "type_value": "integer" 694 + }' 695 + 696 + # Create a range constraint for salary 697 + curl -X POST http://localhost:3000/api/v1/constraints \ 698 + -H "Content-Type: application/json" \ 699 + -H "Authorization: Bearer <token>" \ 700 + -d '{ 701 + "constraint_type": "range", 702 + "label": "Employee", 703 + "property": "salary", 704 + "min_value": 30000, 705 + "max_value": 200000 706 + }' 707 + 708 + # Try to create an employee without email (will fail) 709 + curl -X POST http://localhost:3000/api/v1/nodes \ 710 + -H "Content-Type: application/json" \ 711 + -H "Authorization: Bearer <token>" \ 712 + -d '{ 713 + "labels": ["Employee"], 714 + "properties": { 715 + "name": "John Doe", 716 + "salary": 50000 717 + } 718 + }' 719 + # Response: {"error": "Validation error: Required property 'email' is missing", "code": 400} 720 + 721 + # Create an employee with all required properties 722 + curl -X POST http://localhost:3000/api/v1/nodes \ 723 + -H "Content-Type: application/json" \ 724 + -H "Authorization: Bearer <token>" \ 725 + -d '{ 726 + "labels": ["Employee"], 727 + "properties": { 728 + "name": "John Doe", 729 + "email": "john@example.com", 730 + "salary": 50000 731 + } 732 + }' 561 733 ``` 562 734 563 735 ### Running Graph Algorithms
+29
src/server/rest.rs
··· 985 985 } 986 986 } 987 987 }, 988 + "constraints": { 989 + "POST /api/v1/constraints": { 990 + "description": "Create a schema constraint", 991 + "request_body": { 992 + "constraint_type": "required", 993 + "label": "Employee", 994 + "property": "email" 995 + }, 996 + "response": { 997 + "id": "required:Employee:email", 998 + "constraint_type": "required", 999 + "label": "Employee", 1000 + "property": "email", 1001 + "details": {} 1002 + } 1003 + }, 1004 + "GET /api/v1/constraints": { 1005 + "description": "List all schema constraints", 1006 + "response": [ 1007 + { 1008 + "id": "required:Employee:email", 1009 + "constraint_type": "required", 1010 + "label": "Employee", 1011 + "property": "email", 1012 + "details": {} 1013 + } 1014 + ] 1015 + } 1016 + }, 988 1017 "docs": { 989 1018 "GET /api/v1/docs": { 990 1019 "description": "This API documentation",