Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

All Situations which have their Broadcast Period which intercepts the Request Time Scope are scoped to build the request response:

...

Chouette Valid

In progress… This Sprint is the first release covering our Feature Plan - Chouette Valid - Ruleset management

Define a Ruleset by JSON

The user can define the Rules and their Rule Contexts via a JSON file:

Code Block
languagejson
[
  { 
    "rule_context": "resource/kind_of",
    "classes": ["Quay", "StopPlace"],
    "rules": [
      {
        "rule": "attribute/mandatory",
        "name": "latitude",
        "criticity": "error",
        "code": "latitude-mandatory",
        "message": "Una parada debe estar ubicada geográficamente. Indicar una latitud"
      },
      {
        "rule": "attribute/mandatory",
        "name": "longitude",
        "criticity": "error",
        "code": "longitude-mandatory",
        "message": "Una parada debe estar ubicada geográficamente Indicar una longitud"
      }
    ]
  },
  {
    "rule": "reference/exists",
    "referenced_classes": ["Quay", "StopPlace", ..., "OperationPeriod"],
    "criticity": "warning",
    "code": "unknown-reference"
  }
]

Available Rule Contexts

  • resource/kind_of: only validate NeTEx Resources of the given classes

  • attribute/match: only validate NeTEx Resources where the given attribute value matches the given expression

  • reduce/element

    Status
    colourGreen
    titleNEW
    : only validate an element of NeTEx Resources

  • reduce/collection

    Status
    colourGreen
    titleNEW
    : only validate elements present in a collection of NeTEx Resources

Available Rules

  • attribute/mandatory: NeTEx resource must have a value for the given attribute

  • attribute/blank

    Status
    colourGreen
    titleNEW
    : NeTEx resource must have a value for the given attribute

  • attribute/value: NeTEx resource must have the given value for the given attribute

  • attribute/match: NeTEx resource must have a value for the given attribute which matches the given expression

  • resource/mandatory: At least a selected NeTEx Resource must be present

  • resource/class: the NeTEx resource must have the given class (ex: ServiceJourneyPattern)

  • collection/count: the NeTEx resource must have a compatible element count in the given collection

  • reference/exists: the NeTEx reference of the given class must match an existing resource

  • reference/version: the NeTEx reference must have a version which matches the given value (ex: any)

  • tag/match: the NeTEx resource has a tag which matches the given expression

Manage rulesets by API

The user can manage his own Rulesets by using the Chouette Valid API.

A Ruleset is defined by:

  • a name

  • a slug

  • a (JSON) definition

Code Block
curl -X POST https://chouette-valid.enroute.mobi/api/v1/rulesets -d@-
{
  "ruleset": {
    "name":"Test Ruleset",
    "slug":"test",
    "definition":"[{\"rule\": \"attribute/mandatory\",...}]"
  }
}

Manage rulesets with CLI

The user can create a Ruleset via the secretary-client command line:

Code Block
languagebash
➜ secretary-client create ruleset --name=Test --slug=test sample.json
Ruleset created for sample.json

The user can update a Ruleset:

Code Block
languagebash
➜ secretary-client patch ruleset test --name="Updated ruleset" --definition=sample.json
Ruleset test updated

The user can delete a Ruleset:

Code Block
➜ secretary-client delete ruleset test
Ruleset test deleted

Provide a NeTEx Starter Kit ruleset

The user can use a Ruleset enroute:starter-kit to valide NeTEx files with these common rules:

  • A StopPlace, Line, Operator, Network, GroupOfLines has a Name

  • A ShortName have 12 or less than characters

  • A PublicCode have 12 or less than characters

  • A StopPlace or StopPlaceEntrance have a Location (Longitude & Latitude)

  • A Line has a TransportMode attribute

  • A Line has a Presentation and a Presentation color (warning)

  • A Line doesn’t define its own routes

  • A Route has a LineRef

  • A (Service)JourneyPattern has a RouteRef

  • A ServiceJourney has a JourneyPatternRef

  • A (Service)JourneyPattern has two or more pointsInSequence

  • A ServiceJourney has one or more dayTypes

  • A ServiceJourney has two or more passingTimes

  • A Destination Display have a FrontText attribute

  • A PassengerStopAssignment has a ScheduledStopPointRef

  • Any NeTEx ID uses less than 256 characters (warning)

  • TimedPassingTimes are with chronological passing times

  • Referenced Resources are present for ScheduledStopPoint, Operator, DayType, Route, JourneyPattern, DestinationDisplay, Direction and RoutePoint

Code Block
➜ secretary-client create validation --wait --ruleset=enroute:starter-kit --include-schema=false sample.zip
Validation 2ff56368-89f9-4ae2-a92c-6d8255273955 created for sample.zip
Wait .

Id: 2ff56368-89f9-4ae2-a92c-6d8255273955
User Status: failed
Ruleset: enroute:starter-kit
Include Schema: false
Schema Version: master
Created at: 2025-02-26 08:48:15.774 +0100 CET
Started at: 2025-02-26 08:48:19.121 +0100 CET
Ended at: 2025-02-26 08:48:19.195 +0100 CET

Messages:
Code: name-mandatory
Criticity: error
Message: A StopPlace, Line, Operator, Network, GroupOfLines has a Name
Resource: sample.xml:8:9

1 Messages

Retrieve Validation status and messages with CLI

The user can retrieve the validation status:

Code Block
languagebash
➜ secretary-client get validation d447ef92-4e58-4ec7-8e40-7db37df83585                                    
Id: d447ef92-4e58-4ec7-8e40-7db37df83585
User Status: pending
Ruleset: test
Include Schema: true
Schema Version: master
Created at: 2025-02-26 08:42:20.997 +0100 CET
Started at: 2025-02-26 08:42:26.787 +0100 CET

➜ secretary-client get validation d447ef92-4e58-4ec7-8e40-7db37df83585
Id: d447ef92-4e58-4ec7-8e40-7db37df83585
User Status: failed
Ruleset: test
Include Schema: true
Schema Version: master
Created at: 2025-02-26 08:42:20.997 +0100 CET
Started at: 2025-02-26 08:42:26.787 +0100 CET
Ended at: 2025-02-26 08:42:37.983 +0100 CET

The user can retrieve the validation messages:

Code Block
languagebash
➜ secretary-client messages validation d447ef92-4e58-4ec7-8e40-7db37df83585
Code: xsd-1845
Criticity: error
Message: Element 'sample': No matching global declaration available for the validation root.
Resource: /tmp/ActiveStorage-5b3cfff1-1468-47d0-91bf-fed93c56a257-20250226-928304-3ynshn.xml:2:0

Code: longitude-mandatory
Criticity: error
Message: Una parada debe estar ubicada geográficamente Indicar una longitud
Resource: :11:3

Code: latitude-mandatory
Criticity: warning
Message: Una parada debe estar ubicada geográficamente Indicar una latitud
Resource: :11:3

The user can create and wait the Validation result:

Code Block
languagebash
➜ secretary-client create validation --wait --ruleset=enroute:starter-kit --include-schema=false sample.zip
Validation 2ff56368-89f9-4ae2-a92c-6d8255273955 created for sample.zip
Wait .

Id: 2ff56368-89f9-4ae2-a92c-6d8255273955
User Status: failed
Ruleset: enroute:starter-kit
Include Schema: false
Schema Version: master
Created at: 2025-02-26 08:48:15.774 +0100 CET
Started at: 2025-02-26 08:48:19.121 +0100 CET
Ended at: 2025-02-26 08:48:19.195 +0100 CET

Messages:
Code: name-mandatory
Criticity: error
Message: A StopPlace, Line, Operator, Network, GroupOfLines has a Name
Resource: sample.xml:8:9

1 Messages

Documentation

The Chouette documentation has been improved with many updates in the English version:

...