本文整理匯總了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))
}
示例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)
})
示例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)
})
示例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)
})
})
示例5: sortDates
availability.unavailableDates = sortDates(unavailableDates).map(date => LocalDate.fromObject(date))
示例6:
.map(date => LocalDate.fromObject(date))
示例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))
})