2023-03-29 17:56:42 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import { Validator } from "./Validator"
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-29 17:21:20 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import StringValidator from "./Validators/StringValidator"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import TextValidator from "./Validators/TextValidator"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import DateValidator from "./Validators/DateValidator"
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-29 17:56:42 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import NatValidator from "./Validators/NatValidator"
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-29 17:21:20 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import IntValidator from "./Validators/IntValidator"
							 | 
						
					
						
							
								
									
										
										
										
											2025-04-08 02:42:30 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import DistanceValidator from "./Validators/DistanceValidator"
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-29 17:21:20 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import DirectionValidator from "./Validators/DirectionValidator"
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-29 17:56:42 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import WikidataValidator from "./Validators/WikidataValidator"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import PNatValidator from "./Validators/PNatValidator"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import FloatValidator from "./Validators/FloatValidator"
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-29 17:21:20 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import PFloatValidator from "./Validators/PFloatValidator"
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-29 17:56:42 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import EmailValidator from "./Validators/EmailValidator"
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-29 17:21:20 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import UrlValidator from "./Validators/UrlValidator"
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-29 17:56:42 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import PhoneValidator from "./Validators/PhoneValidator"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import OpeningHoursValidator from "./Validators/OpeningHoursValidator"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import ColorValidator from "./Validators/ColorValidator"
							 | 
						
					
						
							
								
									
										
										
										
											2023-06-20 01:32:24 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import SimpleTagValidator from "./Validators/SimpleTagValidator"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import ImageUrlValidator from "./Validators/ImageUrlValidator"
							 | 
						
					
						
							
								
									
										
										
										
											2023-06-23 16:14:43 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import TagKeyValidator from "./Validators/TagKeyValidator"
							 | 
						
					
						
							
								
									
										
										
										
											2023-06-30 13:36:02 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import TranslationValidator from "./Validators/TranslationValidator"
							 | 
						
					
						
							
								
									
										
										
										
											2023-08-10 16:25:25 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import FediverseValidator from "./Validators/FediverseValidator"
							 | 
						
					
						
							
								
									
										
										
										
											2023-08-23 11:11:53 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import IconValidator from "./Validators/IconValidator"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import TagValidator from "./Validators/TagValidator"
							 | 
						
					
						
							
								
									
										
										
										
											2023-10-07 03:07:32 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import IdValidator from "./Validators/IdValidator"
							 | 
						
					
						
							
								
									
										
										
										
											2023-12-14 16:57:47 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import SlopeValidator from "./Validators/SlopeValidator"
							 | 
						
					
						
							
								
									
										
										
										
											2024-01-11 05:10:04 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import VeloparkValidator from "./Validators/VeloparkValidator"
							 | 
						
					
						
							
								
									
										
										
										
											2024-04-25 00:56:36 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import NameSuggestionIndexValidator from "./Validators/NameSuggestionIndexValidator"
							 | 
						
					
						
							
								
									
										
										
										
											2024-04-27 01:47:51 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import CurrencyValidator from "./Validators/CurrencyValidator"
							 | 
						
					
						
							
								
									
										
										
										
											2024-09-17 02:51:02 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import RegexValidator from "./Validators/RegexValidator"
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-29 17:21:20 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-06-14 20:44:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								export type ValidatorType = (typeof Validators.availableTypes)[number]
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-30 04:51:56 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-29 17:21:20 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								export default class Validators {
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-30 04:51:56 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    public static readonly availableTypes = [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        "string",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        "text",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        "date",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        "nat",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        "int",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        "distance",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        "direction",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        "wikidata",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        "pnat",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        "float",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        "pfloat",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        "email",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        "url",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        "phone",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        "opening_hours",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        "color",
							 | 
						
					
						
							
								
									
										
										
										
											2023-06-23 16:14:43 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        "image",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        "simple_tag",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        "key",
							 | 
						
					
						
							
								
									
										
										
										
											2023-06-30 13:36:02 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        "translation",
							 | 
						
					
						
							
								
									
										
										
										
											2023-08-23 11:11:53 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        "icon",
							 | 
						
					
						
							
								
									
										
										
										
											2023-08-10 16:25:25 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        "fediverse",
							 | 
						
					
						
							
								
									
										
										
										
											2023-08-23 11:11:53 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        "tag",
							 | 
						
					
						
							
								
									
										
										
										
											2023-09-16 18:52:42 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        "fediverse",
							 | 
						
					
						
							
								
									
										
										
										
											2023-10-07 03:07:32 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        "id",
							 | 
						
					
						
							
								
									
										
										
										
											2023-12-14 16:57:47 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        "slope",
							 | 
						
					
						
							
								
									
										
										
										
											2024-02-20 13:33:38 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        "velopark",
							 | 
						
					
						
							
								
									
										
										
										
											2024-04-25 00:56:36 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        "nsi",
							 | 
						
					
						
							
								
									
										
										
										
											2024-06-16 16:06:26 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        "currency",
							 | 
						
					
						
							
								
									
										
										
										
											2024-10-19 14:44:55 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        "regex",
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-30 04:51:56 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    ] as const
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    public static readonly AllValidators: ReadonlyArray<Validator> = [
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-29 17:21:20 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        new StringValidator(),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        new TextValidator(),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        new DateValidator(),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        new NatValidator(),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        new IntValidator(),
							 | 
						
					
						
							
								
									
										
										
										
											2025-04-08 02:42:30 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        new DistanceValidator(),
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-29 17:21:20 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        new DirectionValidator(),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        new WikidataValidator(),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        new PNatValidator(),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        new FloatValidator(),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        new PFloatValidator(),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        new EmailValidator(),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        new UrlValidator(),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        new PhoneValidator(),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        new OpeningHoursValidator(),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        new ColorValidator(),
							 | 
						
					
						
							
								
									
										
										
										
											2023-06-20 01:32:24 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        new ImageUrlValidator(),
							 | 
						
					
						
							
								
									
										
										
										
											2023-06-22 15:07:14 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        new SimpleTagValidator(),
							 | 
						
					
						
							
								
									
										
										
										
											2023-08-23 11:11:53 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        new TagValidator(),
							 | 
						
					
						
							
								
									
										
										
										
											2023-06-23 16:14:43 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        new TagKeyValidator(),
							 | 
						
					
						
							
								
									
										
										
										
											2023-06-30 13:36:02 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        new TranslationValidator(),
							 | 
						
					
						
							
								
									
										
										
										
											2023-08-23 11:11:53 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        new IconValidator(),
							 | 
						
					
						
							
								
									
										
										
										
											2023-08-10 16:25:25 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        new FediverseValidator(),
							 | 
						
					
						
							
								
									
										
										
										
											2023-10-07 03:07:32 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        new IdValidator(),
							 | 
						
					
						
							
								
									
										
										
										
											2023-12-14 16:57:47 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        new SlopeValidator(),
							 | 
						
					
						
							
								
									
										
										
										
											2024-02-20 13:33:38 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        new VeloparkValidator(),
							 | 
						
					
						
							
								
									
										
										
										
											2024-04-25 00:56:36 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        new NameSuggestionIndexValidator(),
							 | 
						
					
						
							
								
									
										
										
										
											2024-06-16 16:06:26 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        new CurrencyValidator(),
							 | 
						
					
						
							
								
									
										
										
										
											2024-10-19 14:44:55 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        new RegexValidator(),
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-29 17:21:20 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-30 04:51:56 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    private static _byType = Validators._byTypeConstructor()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2024-07-12 03:17:15 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    public static HelpText(): string {
							 | 
						
					
						
							
								
									
										
										
										
											2024-07-21 10:52:51 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const explanations: string[] = Validators.AllValidators.flatMap((type) => [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            "### " + type.name,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            type.explanation,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        ])
							 | 
						
					
						
							
								
									
										
										
										
											2024-07-12 03:17:15 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            "# Available types for text fields",
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-29 17:21:20 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            "The listed types here trigger a special input element. Use them in `tagrendering.freeform.type` of your tagrendering to activate them",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            ...explanations,
							 | 
						
					
						
							
								
									
										
										
										
											2024-07-12 03:17:15 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        ].join("\n")
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-29 17:21:20 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-08-23 11:11:53 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    private static _byTypeConstructor(): Map<ValidatorType, Validator> {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        const map = new Map<ValidatorType, Validator>()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        for (const validator of Validators.AllValidators) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            map.set(<ValidatorType>validator.name, validator)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return map
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-30 04:51:56 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    static get(type: ValidatorType): Validator {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return Validators._byType.get(type)
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-29 17:21:20 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 |