当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript LocalDate.fromObject方法代码示例

本文整理汇总了TypeScript中forms/models/localDate.LocalDate.fromObject方法的典型用法代码示例。如果您正苦于以下问题:TypeScript LocalDate.fromObject方法的具体用法?TypeScript LocalDate.fromObject怎么用?TypeScript LocalDate.fromObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在forms/models/localDate.LocalDate的用法示例。


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

示例1: fromObject

  static fromObject (input?: any): DatePaid {
    if (!input) {
      return input
    }

    return new DatePaid(LocalDate.fromObject(input.date))
  }
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:7,代码来源:datePaid.ts

示例2: it

    it('should reject incomplete date', () => {
      const errors = validator.validateSync(new ReportRow(
        'Sarah Ross',
        LocalDate.fromObject({ year: 2019, day: 5 })
      ))

      expect(errors).to.not.be.empty
      expectValidationError(errors, DateValidationErrors.MONTH_NOT_VALID)
    })
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:9,代码来源:reportRow.ts

示例3: it

 it('invalid', () => {
   const dateInThePast = LocalDate.fromObject({ day: 33, month: 13, year: 1990 })
   const errors = validator.validateSync(new HowMuchHaveYouPaid(validAmount, dateInThePast, validText))
   expect(errors.length).to.equal(1)
   expectValidationError(errors, LocalDateValidationErrors.DAY_NOT_VALID)
 })
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:6,代码来源:howMuchHaveYouPaid.ts

示例4: Validator

/* tslint:disable:no-unused-expression */
import { expect } from 'chai'
import { HowMuchHaveYouPaid, ValidationErrors } from 'response/form/models/howMuchHaveYouPaid'
import { ValidationErrors as DefaultValidationErrors } from 'forms/validation/validationErrors'
import { LocalDate, ValidationErrors as LocalDateValidationErrors } from 'forms/models/localDate'
import { generateString, expectValidationError } from 'test/app/forms/models/validationUtils'
import { ValidationConstraints } from 'forms/validation/validationConstraints'
import { Validator } from '@hmcts/class-validator'

const validLocalDate = LocalDate.fromObject({ day: 1, month: 1, year: 2010 })
const validAmount = 100
const validText = 'valid'

describe('HowMuchHaveYouPaid', () => {
  const validator: Validator = new Validator()

  context('should not be valid when', () => {
    context('amount is', () => {
      it('eq 0', () => {
        const errors = validator.validateSync(new HowMuchHaveYouPaid(0, validLocalDate, validText))
        expect(errors.length).to.equal(1)
        expectValidationError(errors, ValidationErrors.AMOUNT_NOT_VALID)
      })

      it('less than 0', () => {
        const errors = validator.validateSync(new HowMuchHaveYouPaid(-10, validLocalDate, validText))
        expect(errors.length).to.equal(1)
        expectValidationError(errors, ValidationErrors.AMOUNT_NOT_VALID)
      })
    })
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:30,代码来源:howMuchHaveYouPaid.ts

示例5: sortDates

 availability.unavailableDates = sortDates(unavailableDates).map(date => LocalDate.fromObject(date))
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:1,代码来源:hearing-dates-picker.ts

示例6:

 .map(date => LocalDate.fromObject(date))
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:1,代码来源:hearing-dates-picker.ts

示例7: it

 it('should convert non numeric field values into numeric type', () => {
   expect(LocalDate.fromObject({ year: '2017', month: '12', day: '31' })).to.deep.equal(new LocalDate(2017, 12, 31))
 })
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:3,代码来源:localDate.ts


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