MapComplete/src/UI/InputElement/Validators/TranslationValidator.ts

19 lines
461 B
TypeScript
Raw Normal View History

import { Validator } from "../Validator"
export default class TranslationValidator extends Validator {
2023-08-23 11:11:53 +02:00
public readonly isMeta = true
constructor() {
super("translation", "Makes sure the the string is of format `Record<string, string>` ")
}
isValid(value: string, getCountry?: () => string): boolean {
try {
JSON.parse(value)
return true
} catch (e) {
return false
}
}
}