mapcomplete/UI/InputElement/Validators/DirectionValidator.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

17 lines
454 B
TypeScript
Raw Normal View History

import IntValidator from "./IntValidator"
import { Validator } from "../Validator"
2023-03-29 17:21:20 +02:00
export default class DirectionValidator extends IntValidator {
constructor() {
super(
"direction",
"A geographical direction, in degrees. 0° is north, 90° is east, ... Will return a value between 0 (incl) and 360 (excl)"
)
}
reformat(str): string {
const n = Number(str) % 360
return "" + n
}
}