import joi from "joi" ; import { FormPayload } from "../types" ; import { PageController } from "./PageController" ; deprecated export class DobPageController extends PageController { constructor ( model = { } , pageDef = { } ) { super ( model , pageDef ) ; this . stateSchema = this . stateSchema . append ( { ageGroup : joi . string ( ) . required ( ) . valid ( "junior" , "full" , "senior" ) , } ) ; } getStateFromValidForm ( formData ) { const state = super . getStateFromValidForm ( formData ) ; const age = Math . floor ( ( Date . now ( ) - state . dob ) / 31557600000 ) ; state . ageGroup = age < 13 ? "junior" : age > 65 ? "senior" : "full" ; return state ; } }