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
  • equals
  • isBefore
  • isAfter
  • isInSet
  • hasYear
  • hasMonth
  • hasDay
  • hasHour
  • hasMinutes
  • hasSeconds
  • hasTimezone
  1. Domain Specifications
  2. DS-V2
  3. DS-V2 - Grammar
  4. Rules Grammar

Grammar Documentation for node type "DateTimeRule"

DateTime: A combination of date and time in ISO 8691 date and time format. 

Schema.org demands the format: 
[-]YYYY-MM-DDThh:mm:ss[Z|(+|-)hh:mm] 

which is a concatenation of four elements: 
Date + “T” + Time + Timezone. 

Date: [-]YYYY-MM-DD , YYYY being the year, MM being the month and DD being the day. 

The letter “T” is just a separation indicator between Date and Time. 

Time: hh:mm:ss , hh being the hour in 24-hour timekeeping system, mm being the minutes and ss being the seconds. 

The Timezone can be unconsidered (not written at all) 
or considered but not specified (the letter “Z” is written) 
or stated in the format: (+|-)hh:mm , hh being the hour in 24-hour timekeeping system, mm being the minutes.

DateTimeRules are rules that apply on values which have the data type "DateTime" from Schema.org.

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. Note that the "subject" property can be omitted, if the "$path" object has an empty JSON Pointer as value (see Meta_Rules.md for details).

However, the data type for the "parameter" depends on the "$rule" value (e.g. arguments for the rule function), and is explained in the following.

equals

The "equals" rule checks if a given DateTime value (the validated value) matches a given DateTime.

{
  "$type": "DateTimeRule",
  "$rule": "equals",
  "subject": {
      "$path": "/checkoutTime"
  },
  "parameter": "2018-04-20T13:37:00"
}

The parameter is a DateTime which serves as the second argument for the rule function. The validated subject must be the same as the given parameter.

isBefore

The "isBefore" rule checks if a given DateTime value (the validated value) is chronologically before a given DateTime.

{
  "$type": "DateTimeRule",
  "$rule": "isBefore",
  "parameter": "2018-04-25T22:00:00"
}

The parameter is a DateTime which serves as the second argument for the rule function. The validated subject must be chronologically before the given parameter.

isAfter

The "isAfter" rule checks if a given DateTime (the validated value) is chronologically after a given DateTime.

{
  "$type": "DateTimeRule",
  "$rule": "isAfter",
  "parameter": "2015-02-05T09:00:00Z"
}

The parameter is a DateTime which serves as the second argument for the rule function. The validated subject must be chronologically after the given parameter.

isInSet

The "isInSet" rule checks if a given DateTime (the validated value) is in the given set of allowed values.

{
  "$type": "DateTimeRule",
  "$rule": "isInSet",
  "parameter": [
    "2014-04-05T09:00:00",
    "2014-04-06T10:00:00Z",
    "2014-04-07T11:30:00"
  ],
  "description": "The DateTime must match one of the given values"
}

The parameter is an array which contains DateTimes, which are valid instances for a given DateTime (the validated subject).

hasYear

The "hasYear" rule checks if a given DateTime (the validated value) has a value for the year, that is conform to a given numeric pattern.

{
  "$type": "DateTimeRule",
  "$rule": "hasYear",
  "parameter": ">2015",
  "description": "Year of the datetime must be later than 2015."
}

The parameter is a numeric pattern, that has to be matched by the year of a given DateTime (the validated subject).

hasMonth

The "hasMonth" rule checks if a given DateTime (the validated value) has a value for the month, that is conform to a given numeric pattern.

{
  "$type": "DateTimeRule",
  "$rule": "hasMonth",
  "parameter": "1-3",
  "description": "The month of the datetime must match the numeric pattern -> Month must be between 1 and 3."
}

The parameter is a numeric pattern, that has to be matched by the month of a given DateTime (the validated subject).

hasDay

The "hasDay" rule checks if a given DateTime (the validated value) has a value for the day, that is conform to a given numeric pattern.

{
  "$type": "DateTimeRule",
  "$rule": "hasDay",
  "parameter": "(15 | 30)",
  "description": "The day of the datetime must match the numeric pattern -> Day must be either 15 or 30."
}

The parameter is a numeric pattern, that has to be matched by the day of a given DateTime (the validated subject).

hasHour

The "hasHour" rule checks if a given DateTime (the validated value) has a value for the hour, that is conform to a given numeric pattern.

{
  "$type": "DateTimeRule",
  "$rule": "hasHour",
  "parameter": "(>7 & < 18)"
}

The parameter is a numeric pattern, that has to be matched by the hour of a given DateTime (the validated subject).

hasMinutes

The "hasMinutes" rule checks if a given DateTime (the validated value) has a value for the minutes, that is conform to a given numeric pattern.

{
  "$type": "DateTimeRule",
  "$rule": "hasMinutes",
  "parameter": "(0 | 15 | 30 | 45)"
}

The parameter is a numeric pattern, that has to be matched by the minutes of a given DateTime (the validated subject).

hasSeconds

The "hasSeconds" rule checks if a given DateTime (the validated value) has a value for the seconds, that is conform to a given numeric pattern.

{
  "$type": "DateTimeRule",
  "$rule": "hasSeconds",
  "parameter": "0"
}

The parameter is a numeric pattern, that has to be matched by the seconds of a given DateTime (the validated subject).

hasTimezone

The "hasTimezone" rule checks if a given DateTime (the validated value) has a value for the timezone, that matches a given value with format: (+|-)hh:mm

{
  "$type": "DateTimeRule",
  "$rule": "hasTimezone",
  "parameter": "+02:00"
}

The parameter is a timezone string with format (+|-)hh:mm that has to be matched by the timezone of a given DateTime (the validated subject). "Z" or a not defined timezone are handled as a not fulfilled constraint.

PreviousGrammar Documentation for node type "BooleanRule"NextDS-V2 - Examples

Last updated 4 years ago

Syntax diagram