當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。