本文整理汇总了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))
})