2023-03-29 17:56:42 +02:00
import { Validator } from "../Validator"
2024-10-07 01:27:44 +02:00
import MarkdownUtils from "../../../Utils/MarkdownUtils"
2023-03-29 17:21:20 +02:00
export default class OpeningHoursValidator extends Validator {
constructor ( ) {
super (
"opening_hours" ,
2024-10-07 01:27:44 +02:00
[
2023-03-29 17:21:20 +02:00
"Has extra elements to easily input when a POI is opened." ,
2025-04-08 02:48:58 +02:00
"#### Helper arguments" ,
2024-10-07 01:27:44 +02:00
"Only one helper argument named `options` can be provided. It is a JSON-object of type `{ prefix: string, postfix: string }`:" ,
MarkdownUtils . table (
[ "subarg" , "doc" ] ,
2023-03-29 17:21:20 +02:00
[
[
2024-10-07 01:27:44 +02:00
"prefix" ,
2024-10-19 14:44:55 +02:00
"Piece of text that will always be added to the front of the generated opening hours. If the OSM-data does not start with this, it will fail to parse." ,
2023-03-29 17:21:20 +02:00
] ,
2024-10-07 01:27:44 +02:00
[
"postfix" ,
2024-10-19 14:44:55 +02:00
"Piece of text that will always be added to the end of the generated opening hours" ,
] ,
]
) ,
2025-04-08 02:48:58 +02:00
"#### Example usage" ,
2023-03-29 17:21:20 +02:00
"To add a conditional (based on time) access restriction:\n\n```\n" +
2024-10-19 14:44:55 +02:00
`
2023-03-29 17:21:20 +02:00
"freeform" : {
"key" : "access:conditional" ,
"type" : "opening_hours" ,
"helperArgs" : [
{
"prefix" : "no @ (" ,
"postfix" : ")"
}
]
} ` +
2024-10-19 14:44:55 +02:00
"\n```\n\n*Don't forget to pass the prefix and postfix in the rendering as well*: `{opening_hours_table(opening_hours,yes @ &LPARENS, &RPARENS )`" ,
2024-10-07 01:27:44 +02:00
] . join ( "\n" )
2023-03-29 17:21:20 +02:00
)
}
}