• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript formValidator.FormValidator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中main/app/forms/validation/formValidator.FormValidator的典型用法代码示例。如果您正苦于以下问题:TypeScript FormValidator类的具体用法?TypeScript FormValidator怎么用?TypeScript FormValidator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了FormValidator类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: buildRouter

  buildRouter (path: string, ...guards: express.RequestHandler[]): express.Router {
    return express.Router()
      .get(path + Paths.paymentOptionPage.uri,
        ...guards,
        (req: express.Request, res: express.Response) => {
          this.renderView(new Form(this.createModelAccessor().get(res.locals.draft.document).paymentOption), res)
        })
      .post(path + Paths.paymentOptionPage.uri,
        ...guards,
        FormValidator.requestHandler(PaymentOption, PaymentOption.fromObject),
        ErrorHandling.apply(
          async (req: express.Request, res: express.Response): Promise<void> => {
            const form: Form<PaymentOption> = req.body

            if (form.hasErrors()) {
              this.renderView(form, res)
            } else {
              this.createModelAccessor().patch(res.locals.draft.document, model => model.paymentOption = form.model)
              this.deleteRedundantData(res, req)

              await this.saveDraft(res.locals)

              res.redirect(this.buildPostSubmissionUri(path, req, res))
            }
          }))
  }
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:26,代码来源:payment-option.ts


示例2: Form

/* tslint:disable:no-default-export */
export default express.Router()
  .get(
    page.uri,
    StatementOfMeansStateGuard.requestHandler(),
    (req: express.Request, res: express.Response) => {
      const draft: Draft<ResponseDraft> = res.locals.responseDraft
      res.render(page.associatedView, {
        form: new Form(draft.document.statementOfMeans.partnerPension)
      })
    })
  .post(
    page.uri,
    StatementOfMeansStateGuard.requestHandler(),
    FormValidator.requestHandler(PartnerPension),
    ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction) => {
      const form: Form<PartnerPension> = req.body
      const { externalId } = req.params

      if (form.hasErrors()) {
        res.render(page.associatedView, { form: form })
      } else {
        const draft: Draft<ResponseDraft> = res.locals.responseDraft
        const user: User = res.locals.user

        draft.document.statementOfMeans.partnerPension = form.model
        await new DraftService().save(draft, user.bearerToken)

        if (draft.document.statementOfMeans.disability && draft.document.statementOfMeans.disability.option === DisabilityOption.YES) {
          res.redirect(StatementOfMeansPaths.partnerDisabilityPage.evaluateUri({ externalId: externalId }))
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:30,代码来源:partner-pension.ts


示例3: Form

/* tslint:disable:no-default-export */
export default express.Router()
  .get(
    page.uri,
    StatementOfMeansStateGuard.requestHandler(),
    (req: express.Request, res: express.Response) => {
      const draft: Draft<ResponseDraft> = res.locals.responseDraft
      res.render(page.associatedView, {
        form: new Form(draft.document.statementOfMeans.cohabiting)
      })
    })
  .post(
    page.uri,
    StatementOfMeansStateGuard.requestHandler(),
    FormValidator.requestHandler(Cohabiting),
    ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction) => {
      const form: Form<Cohabiting> = req.body
      const { externalId } = req.params

      if (form.hasErrors()) {
        res.render(page.associatedView, { form: form })
      } else {
        const draft: Draft<ResponseDraft> = res.locals.responseDraft
        const user: User = res.locals.user

        draft.document.statementOfMeans.cohabiting = form.model
        if (form.model.option === CohabitingOption.NO) {
          draft.document.statementOfMeans.partnerAge = draft.document.statementOfMeans.partnerDisability =
            draft.document.statementOfMeans.partnerSevereDisability = draft.document.statementOfMeans.partnerPension =
              undefined
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:30,代码来源:partner.ts


示例4: renderView

  })
}

/* tslint:disable:no-default-export */
export default express.Router()
  .get(
    Paths.courtOfferedSetDatePage.uri,
    ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction) => {
      const draft: Draft<DraftClaimantResponse> = res.locals.claimantResponseDraft

      renderView(new Form(draft.document.acceptCourtOffer), res)
    }))

  .post(
    Paths.courtOfferedSetDatePage.uri,
    FormValidator.requestHandler(AcceptCourtOffer, AcceptCourtOffer.fromObject),
    ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction): Promise<void> => {
      const form: Form<AcceptCourtOffer> = req.body
      if (form.hasErrors()) {
        renderView(form, res)
      } else {
        const draft: Draft<DraftClaimantResponse> = res.locals.claimantResponseDraft
        const user: User = res.locals.user
        const { externalId } = req.params

        draft.document.acceptCourtOffer = form.model

        if (draft.document.courtDetermination.rejectionReason || draft.document.formaliseRepaymentPlan) {
          delete draft.document.courtDetermination.rejectionReason
          delete draft.document.formaliseRepaymentPlan
          delete draft.document.settlementAgreement
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:31,代码来源:court-offered-set-date.ts


示例5: renderView

    form: form,
    totalAmount: StatesPaidHelper.getAlreadyPaidAmount(claim),
    paidInFull: !StatesPaidHelper.isAlreadyPaidLessThanAmount(claim)
  })
}

/* tslint:disable:no-default-export */
export default express.Router()
  .get(Paths.settleClaimPage.uri,
    ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction) => {
      const draft: Draft<DraftClaimantResponse> = res.locals.claimantResponseDraft
      renderView(new Form(draft.document.accepted), res)
    }))
  .post(
    Paths.settleClaimPage.uri,
    FormValidator.requestHandler(ClaimSettled, ClaimSettled.fromObject),
    ErrorHandling.apply(async (req: express.Request, res: express.Response): Promise<void> => {
      const form: Form<ClaimSettled> = req.body
      if (form.hasErrors()) {
        renderView(form, res)
      } else {
        const draft: Draft<DraftClaimantResponse> = res.locals.claimantResponseDraft
        draft.document.accepted = form.model

        if (form.model.accepted.option === YesNoOption.YES.option) {
          draft.document.rejectionReason = undefined
          draft.document.freeMediation = undefined
        }

        await new DraftService().save(draft, res.locals.user.bearerToken)
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:30,代码来源:settle-claim.ts


示例6: catch

    })
  } catch (err) {
    next(err)
  }
}

/* tslint:disable:no-default-export */
export default express.Router()
  .get(
    Paths.signSettlementAgreement.uri,
    ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction) => {
      renderView(new Form(new DefendantSettlementResponse()), res, next)
    }))
  .post(
    Paths.signSettlementAgreement.uri,
    FormValidator.requestHandler(DefendantSettlementResponse),
    ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction): Promise<void> => {
      const form: Form<DefendantSettlementResponse> = req.body

      if (form.hasErrors()) {
        renderView(form, res, next)
      } else {
        const claim: Claim = res.locals.claim
        const user: User = res.locals.user

        if (form.model.option === YesNoOption.YES.option) {
          await settlementAgreementClient.countersignSettlementAgreement(claim.externalId, user)
        } else {
          await settlementAgreementClient.rejectSettlementAgreement(claim.externalId, user)
        }
        res.redirect(Paths.settlementAgreementConfirmation.evaluateUri({ externalId: claim.externalId }))
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:31,代码来源:sign-settlement-agreement.ts


示例7: Form

/* tslint:disable:no-default-export */
export default express.Router()
  .get(
    page.uri,
    StatementOfMeansStateGuard.requestHandler(),
    (req: express.Request, res: express.Response) => {
      const draft: Draft<ResponseDraft> = res.locals.responseDraft
      res.render(page.associatedView, {
        form: new Form(draft.document.statementOfMeans.partnerAge)
      })
    })
  .post(
    page.uri,
    StatementOfMeansStateGuard.requestHandler(),
    FormValidator.requestHandler(PartnerAge),
    ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction) => {
      const form: Form<PartnerAge> = req.body
      const { externalId } = req.params

      if (form.hasErrors()) {
        res.render(page.associatedView, { form: form })
      } else {
        const draft: Draft<ResponseDraft> = res.locals.responseDraft
        const user: User = res.locals.user

        draft.document.statementOfMeans.partnerAge = form.model
        if (form.model.option === PartnerAgeOption.NO) {
          draft.document.statementOfMeans.partnerPension = undefined
        }
        await new DraftService().save(draft, user.bearerToken)
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:30,代码来源:partner-age.ts


示例8: Form

/* tslint:disable:no-default-export */
export default express.Router()
  .get(
    page.uri,
    StatementOfMeansStateGuard.requestHandler(),
    (req: express.Request, res: express.Response) => {
      const draft: Draft<ResponseDraft> = res.locals.responseDraft
      res.render(page.associatedView, {
        form: new Form(draft.document.statementOfMeans.partnerDisability)
      })
    })
  .post(
    page.uri,
    StatementOfMeansStateGuard.requestHandler(),
    FormValidator.requestHandler(PartnerDisability),
    ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction) => {
      const form: Form<PartnerDisability> = req.body
      const { externalId } = req.params

      if (form.hasErrors()) {
        res.render(page.associatedView, { form: form })
      } else {
        const draft: Draft<ResponseDraft> = res.locals.responseDraft
        const user: User = res.locals.user

        draft.document.statementOfMeans.partnerDisability = form.model
        if (form.model.option === PartnerDisabilityOption.NO) {
          draft.document.statementOfMeans.partnerSevereDisability = undefined
        }
        await new DraftService().save(draft, user.bearerToken)
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:30,代码来源:partner-disability.ts


示例9: renderView

function renderView (form: Form<IntentionToProceed>, res: express.Response): void {
  res.render(Paths.intentionToProceedPage.associatedView,{
    form: form
  })
}

/* tslint:disable:no-default-export */
export default express.Router()
  .get(Paths.intentionToProceedPage.uri,
    ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction) => {
      const draft: Draft<DraftClaimantResponse> = res.locals.claimantResponseDraft
      renderView(new Form(draft.document.intentionToProceed), res)
    }))
  .post(
    Paths.intentionToProceedPage.uri,
    FormValidator.requestHandler(IntentionToProceed, IntentionToProceed.fromObject),
    ErrorHandling.apply(async (req: express.Request, res: express.Response): Promise<void> => {
      const form: Form<IntentionToProceed> = req.body
      if (form.hasErrors()) {
        renderView(form, res)
      } else {
        const draft: Draft<DraftClaimantResponse> = res.locals.claimantResponseDraft
        const mediationDraft: Draft<MediationDraft> = res.locals.mediationDraft
        const user: User = res.locals.user
        if (form.model.proceed === YesNoOption.NO.option && mediationDraft) {

          await new DraftService().delete(mediationDraft.id, user.bearerToken)
        }

        draft.document.intentionToProceed = form.model
        await new DraftService().save(draft, user.bearerToken)
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:31,代码来源:intention-to-proceed.ts


示例10: async

  })
}

/* tslint:disable:no-default-export */
export default express.Router()
  .get(
    Paths.willYouTryMediation.uri,
    async (req: express.Request, res: express.Response, next: express.NextFunction) => {
      const draft: Draft<MediationDraft> = res.locals.mediationDraft

      renderView(new Form(draft.document.willYouTryMediation), res)
    }
  )
  .post(
    Paths.willYouTryMediation.uri,
    FormValidator.requestHandler(FreeMediation),
    ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction) => {
      const form: Form<FreeMediation> = req.body
      if (form.hasErrors()) {
        renderView(form, res)
      } else {
        const draft: Draft<MediationDraft> = res.locals.mediationDraft
        const user: User = res.locals.user

        draft.document.willYouTryMediation = form.model

        if (form.model.option === FreeMediationOption.NO) {
          draft.document.youCanOnlyUseMediation = undefined
          draft.document.canWeUse = undefined
          draft.document.canWeUseCompany = undefined
        }
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:31,代码来源:will-you-try-mediation.ts



注:本文中的main/app/forms/validation/formValidator.FormValidator类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript mcall.mcall函数代码示例发布时间:2022-05-25
下一篇:
TypeScript form.Form类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap