DS Specifications
Domain SpecificationsListsVocabularies
main
main
  • DS Specifications Overview
  • Domain Specifications
    • DS-V7
      • DS-V7 - Changelog
      • DS-V7 - Developer Notes
      • DS-V7 - Grammar
        • Domain Specification
          • @Context
          • Domain Specification Node
          • Property Node
          • Class Node
          • DataType Node
          • Enumeration Node
        • Verification Report
          • Verification Report Node
          • Error Entry Node
          • Error List for the domain-specific verification
        • DS-Path
      • DS-V7 - Examples
    • DS-V6
    • DS-V5
      • DS-V5 - Grammar
        • VerificationReport
          • Error List for the basic verification
          • Verification of schema.org annotations
          • Error List for the Meta verification of DS (unfinished)
          • Error List for the DS-based verification
        • Grammar and semantics of Domain Specifications
          • Enumeration Node
          • Property Node
          • Domain Specification Node
          • Class Node
          • Terms used in Domain Specifications
          • @Context
          • DataType Node
      • DS-V5 - Examples
    • DS-V4
    • DS-V3
      • DS-V3 - Examples
      • DS-V3 - Grammar
        • VerificationReport
          • Error List for the basic verification
          • Verification of schema.org annotations
          • Error List for the DS-based verification
          • Error List for the Meta verification of DS
        • Grammar and semantics of Domain Specifications
          • SDO Enumeration
          • SDO Property
          • Domain Specification
          • SDO Class
          • SDO Datatype
          • @Context
    • DS-V2
      • DS-V2 - Grammar
        • Grammar and semantics of Domain Specifications
          • Grammar Documentation for node type "RestrictedEnumeration"
          • Grammar Documentation for node type "CustomEnumerationValue"
          • Grammar Documentation for node type "Enumeration"
          • Grammar Documentation for node type "Property"
          • Grammar Documentation for node type "RestrictedProperty"
          • Grammar Documentation for node type "DomainSpecification"
          • Grammar Documentation for node type "RestrictedClass"
          • Grammar Documentation for node type "EnumerationValue"
          • Grammar Documentation for node type "Class"
          • Grammar Documentation for node type "DataType"
        • Numeric Pattern
        • Grammar Documentation for node type "VerificationReport"
          • Grammar Documentation for node type "Error"
          • Error codes for Verification Reports
        • Rules Grammar
          • Grammar Documentation for node type "ComplexRule"
          • Grammar Documentation for node type "DateRule"
          • Grammar Documentation for node type "TextRule"
          • Grammar Documentation for node type "TimeRule"
          • Grammar Documentation for node type "NumberRule"
          • Grammar Documentation for node type "BooleanRule"
          • Grammar Documentation for node type "DateTimeRule"
      • DS-V2 - Examples
    • DS-V1
      • DS-V1 - Examples
      • DS-V1 - Grammar
  • SDO-Verification
  • Lists
    • List-V1
  • Vocabularies
  • DS-Vocabulary
    • Input
      • Vocabulary for Domain Specifications
      • DS-Vocabulary
    • DS-Vocab-V1
Powered by GitBook
On this page
  • and
  • or
  • not
  • ifThen
  1. Domain Specifications
  2. DS-V2
  3. DS-V2 - Grammar
  4. Rules Grammar

Grammar Documentation for node type "ComplexRule"

ComplexRules are rules that can be used on any data type from schema.org and enable the usage of boolean, and causal logic.

The specific rule type is given by the value in the "$rule" property. The properties which rules can have are explained in the Meta_Rules.md document.

However, there are additional properties a rule may have, depending on the "$rule" value (e.g. arguments for the rule function), which are explained in the following.

and

Based on "AND" from boolean logic. The "and" rule checks if a set of rules passes the semantic validation.

{
  "$type": "ComplexRule",
  "$rule": "and",
  "rules": [
    {
        "$type": "TextRule",
        "$rule": "startsWith",
        "subject": {
            "$path": "/telephone"
        },
        "parameter": "+43512"
    },
    {
        "$type": "TextRule",
        "$rule": "equals",
        "subject": {
            "$path": "/address/addressLocality"
        },
        "parameter": "Innsbruck"
    }
  ],
  "description": "The telephone number must start with '+43512' and the city must be 'Innsbruck'."
}

All rules inside the "rules" array must pass the check, so that this ComplexRule is valid.

or

Based on "OR" from boolean logic. The "or" rule checks if at least one rule from a set of rules passes the semantic validation.

{
  "$type": "ComplexRule",
  "$rule": "or",
  "rules": [
    {
        "$type": "TextRule",
        "$rule": "startsWith",
        "subject": {
            "$path": "/telephone"
        },
        "parameter": "+43"
    },
    {
        "$type": "TextRule",
        "$rule": "startsWith",
        "subject": {
            "$path": "/telephone"
        },
        "parameter": "+49"
    }
  ],
  "description": "The telephone number must be from Austria (+43) or from Germany (+49)."
}

At least one rule inside the "rules" array must pass the check, so that this ComplexRule is valid.

not

Based on "NOT" from boolean logic. The "not" rule checks if a set of rules does NOT pass the semantic validation.

{
  "$type": "ComplexRule",
  "$rule": "not",
  "rules": [
    {
        "$type": "TextRule",
        "$rule": "equals",
        "parameter": "Germany"
    }
  ],
  "description": "The value must not be 'Germany'."
}

All rules inside the "rules" array must NOT pass the check, so that this ComplexRule is valid.

ifThen

The "ifThen" rule enables a conditional restriction based on causal logic. It checks if a set of rules passes the semantic validation (ifRules). If they do, then another set of rules must also pass the semantic validation (thenRules).

{
  "$type": "ComplexRule",
  "$rule": "ifThen",
  "ifRules": [
    {
      "$type": "TextRule",
      "$rule": "equals",
      "subject": {
        "$path": "/address/addressCountry"
      },
      "parameter": "Austria"
    }
  ],
  "thenRules": [
    {
      "$type": "TextRule",
      "$rule": "startsWith",
      "subject": {
        "$path": "/telephone"
      },
      "parameter": "+43"
    }
  ],
  "description": "If the country is Austria, then the telephone number must start with +43."
}

If all the rules inside the "ifRules" array pass the check, then all the rules inside the "thenRules" array must also pass the check.

PreviousRules GrammarNextGrammar Documentation for node type "DateRule"

Last updated 4 years ago