forked from MapComplete/MapComplete
Merge develop
This commit is contained in:
commit
fec3608ca4
57 changed files with 1160 additions and 594 deletions
|
|
@ -220,8 +220,8 @@
|
|||
<td/>
|
||||
{/if}
|
||||
{#each range(7) as wd}
|
||||
<OHCell type="half" {h} {wd} on:start={() => startSelection(wd, h)} on:end={() => endSelection(wd, h)}
|
||||
on:move={() => moved(wd, h)} on:clear={() => clearSelection()} />
|
||||
<OHCell type="half" {h} {wd} on:start={() => startSelection(wd, h + 0.5)} on:end={() => endSelection(wd, h + 0.5)}
|
||||
on:move={() => moved(wd, h + 0.5)} on:clear={() => clearSelection()} />
|
||||
{/each}
|
||||
</tr>
|
||||
|
||||
|
|
|
|||
|
|
@ -15,9 +15,6 @@ import UrlValidator from "./Validators/UrlValidator"
|
|||
import PhoneValidator from "./Validators/PhoneValidator"
|
||||
import OpeningHoursValidator from "./Validators/OpeningHoursValidator"
|
||||
import ColorValidator from "./Validators/ColorValidator"
|
||||
import BaseUIElement from "../BaseUIElement"
|
||||
import Combine from "../Base/Combine"
|
||||
import Title from "../Base/Title"
|
||||
import SimpleTagValidator from "./Validators/SimpleTagValidator"
|
||||
import ImageUrlValidator from "./Validators/ImageUrlValidator"
|
||||
import TagKeyValidator from "./Validators/TagKeyValidator"
|
||||
|
|
@ -30,6 +27,7 @@ import SlopeValidator from "./Validators/SlopeValidator"
|
|||
import VeloparkValidator from "./Validators/VeloparkValidator"
|
||||
import NameSuggestionIndexValidator from "./Validators/NameSuggestionIndexValidator"
|
||||
import CurrencyValidator from "./Validators/CurrencyValidator"
|
||||
import RegexValidator from "./Validators/RegexValidator"
|
||||
|
||||
export type ValidatorType = (typeof Validators.availableTypes)[number]
|
||||
|
||||
|
|
@ -64,6 +62,7 @@ export default class Validators {
|
|||
"velopark",
|
||||
"nsi",
|
||||
"currency",
|
||||
"regex"
|
||||
] as const
|
||||
|
||||
public static readonly AllValidators: ReadonlyArray<Validator> = [
|
||||
|
|
@ -95,6 +94,7 @@ export default class Validators {
|
|||
new VeloparkValidator(),
|
||||
new NameSuggestionIndexValidator(),
|
||||
new CurrencyValidator(),
|
||||
new RegexValidator()
|
||||
]
|
||||
|
||||
private static _byType = Validators._byTypeConstructor()
|
||||
|
|
|
|||
22
src/UI/InputElement/Validators/RegexValidator.ts
Normal file
22
src/UI/InputElement/Validators/RegexValidator.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import StringValidator from "./StringValidator"
|
||||
import { s } from "vitest/dist/env-afee91f0"
|
||||
import { Translation } from "../../i18n/Translation"
|
||||
import Translations from "../../i18n/Translations"
|
||||
|
||||
export default class RegexValidator extends StringValidator{
|
||||
constructor() {
|
||||
super("regex", "Validates a regex")
|
||||
}
|
||||
|
||||
getFeedback(s: string): Translation | undefined {
|
||||
try{
|
||||
new RegExp(s)
|
||||
}catch (e) {
|
||||
return Translations.T("Not a valid Regex: "+e)
|
||||
}
|
||||
}
|
||||
|
||||
isValid(s: string): boolean {
|
||||
return this.getFeedback(s) === undefined
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue