本文整理匯總了TypeScript中forms/validation/validators/isTodayOrInFuture.DateTodayOrInFutureConstraint類的典型用法代碼示例。如果您正苦於以下問題:TypeScript DateTodayOrInFutureConstraint類的具體用法?TypeScript DateTodayOrInFutureConstraint怎麽用?TypeScript DateTodayOrInFutureConstraint使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了DateTodayOrInFutureConstraint類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: describe
describe('DateTodayOrInFutureConstraint', () => {
const constraint: DateTodayOrInFutureConstraint = new DateTodayOrInFutureConstraint()
describe('validate', () => {
describe('should return true when ', () => {
it('given a date is undefined', () => {
expect(constraint.validate(undefined)).to.equal(true)
})
it('given a valid date in the future', () => {
const inFuture = moment().add(10, 'years')
expect(constraint.validate(new LocalDate(inFuture.year(), 1, 1))).to.equal(true)
})
it('given today date', () => {
const now = moment()
expect(constraint.validate(new LocalDate(now.year(), now.month() + 1, now.date()))).to.equal(true)
})
})
describe('should return false when ', () => {
it('given an invalid structure', () => {
expect(constraint.validate({ a: 1, b: 1, c: 2000 })).to.equal(false)
})
it('given a date in the past', () => {
const inPast = moment().subtract(10, 'years')
expect(constraint.validate(new LocalDate(inPast.year(), 8, 8))).to.equal(false)
})
})
})
})
示例2: it
it('given a date in the past', () => {
const inPast = moment().subtract(10, 'years')
expect(constraint.validate(new LocalDate(inPast.year(), 8, 8))).to.equal(false)
})