Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 12, 2026

User requested documentation of the formula and validation rule syntax currently used in the ObjectQL project.

Changes

Documentation added:

  • docs/guide/formulas-and-rules.md (16KB) - Complete English guide covering formula syntax, validation rules, permission rules, operators, and 50+ examples
  • docs/guide/formulas-and-rules-quick-ref.md (5KB) - Condensed syntax reference

Updates:

  • VitePress navigation menu - Added new guides under "Data & Logic Layers"
  • README.md - Added formula field example and link to syntax guide

Coverage

Formula syntax:

  • JavaScript-style expressions with field references
  • Arithmetic, string, date operations
  • Conditional expressions and lookup references via dot notation
  • Special variables: $today, $now, $current_user
# Formula field example
profit_margin:
  type: formula
  expression: "(revenue - cost) / revenue * 100"
  data_type: percent

Validation rules:

  • Field-level (required, min/max, pattern)
  • Cross-field (compare multiple fields)
  • Conditional (apply based on conditions)
  • State machine (enforce transitions)
  • Business rules (complex constraints)
  • Custom (JavaScript functions)
# Cross-field validation example
rules:
  - name: valid_date_range
    type: cross_field
    rule:
      field: end_date
      operator: ">="
      compare_to: start_date
    message: "End date must be after start date"

Operators: Comparison (=, !=, >, >=, <, <=), set membership (in, not_in, contains), logical (all_of, any_of, none_of), special (not_empty, is_null)

All examples verified against actual codebase patterns in /packages/starters/ and /packages/foundation/.

Original prompt

目前项目使用的公式,规则的语法是什么,更新文档给我确认


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits January 12, 2026 12:43
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
@hotlong
Copy link
Contributor

hotlong commented Jan 12, 2026

@copilot 我不需要中文文档,我不想维护两套文档

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI changed the title [WIP] Update documentation for formula and rule syntax Add comprehensive formula and rules syntax documentation Jan 12, 2026
Copilot AI requested a review from hotlong January 12, 2026 13:08
@hotlong
Copy link
Contributor

hotlong commented Jan 12, 2026

@copilot 我的意思是删除中文文档,我不需要

@hotlong hotlong marked this pull request as ready for review January 12, 2026 13:13
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 12, 2026

@copilot 我不需要中文文档,我不想维护两套文档

已删除中文文档和总结文件。现在只保留英文文档:

  • docs/guide/formulas-and-rules.md
  • docs/guide/formulas-and-rules-quick-ref.md

Commit: f3b9c69

Copy link
Contributor Author

Copilot AI commented Jan 12, 2026

@copilot 我的意思是删除中文文档,我不需要

中文文档已在上一个提交中删除 (f3b9c69)。当前只保留英文文档:

  • docs/guide/formulas-and-rules.md
  • docs/guide/formulas-and-rules-quick-ref.md

@hotlong hotlong requested review from Copilot and removed request for hotlong January 12, 2026 13:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds comprehensive documentation for formula and validation rule syntax used in the ObjectQL project. The documentation provides English-language guides for defining calculated fields and business rules.

Changes:

  • Added complete formulas and rules syntax guide with 50+ examples covering formula syntax, validation rules, permission rules, operators, and best practices
  • Added condensed quick reference guide for rapid lookup
  • Updated VitePress navigation to include new guides in "Data & Logic Layers" section
  • Enhanced README.md with formula field example and link to syntax guide

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
docs/guide/formulas-and-rules.md Complete 690-line guide covering formula expressions, validation types, permission rules, operators, and best practices with extensive examples
docs/guide/formulas-and-rules-quick-ref.md 270-line condensed syntax reference for quick lookup of common patterns and operators
docs/.vitepress/config.mts Added navigation menu entries for new guides under "Data & Logic Layers" section with proper indentation
README.md Added formula field example demonstrating calculated fields and updated feature list to include formulas, with link to new syntax guide

hotlong and others added 2 commits January 12, 2026 21:42
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@hotlong hotlong merged commit 64c90be into main Jan 12, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants