it('should return errors when correspondence address fields have too long values', () => {
   let errors: ValidationError[] = validator.validateSync(partyDetails)
   expectValidationError(errors, CorrespondenceAddressValidationErrors.FIRST_LINE_REQUIRED)
   expectValidationError(errors, CorrespondenceAddressValidationErrors.CITY_REQUIRED)
   expectValidationError(errors, CorrespondenceAddressValidationErrors.POSTCODE_REQUIRED)
 })
    it('should reject InterestEndDate with unrecognised type', () => {
      const errors = validator.validateSync(new InterestEndDate('unrecognised-type'))

      expect(errors.length).to.equal(1)
      expectValidationError(errors, ValidationErrors.INTEREST_END_DATE_REQUIRED)
    })
      it('when both are valid strings', () => {
        const errors = validator.validateSync(new EvidenceRow(EvidenceType.OTHER, 'description'))

        expect(errors.length).to.equal(0)
      })
    it('Should reject an invalid option', () => {
      const errors = validator.validateSync(new PartPaymentReceived(YesNoOption.fromObject('invalid option')))

      expect(errors).to.be.length(1)
      expectValidationError(errors, ValidationErrors.YES_NO_REQUIRED)
    })
      it('invalid option', () => {
        const errors = validator.validateSync(new PaymentOption(new PaymentType('unknown')))

        expect(errors.length).to.equal(1)
        expectValidationError(errors, ValidationErrors.OPTION_REQUIRED)
      })
        it('when date in the past', () => {
          const errors = validator.validateSync(new PaymentDate(new LocalDate().deserialize(validDateInThePastObj.date)))

          expect(errors.length).to.equal(1)
          expectValidationError(errors, ValidationErrors.DATE_TODAY_OR_IN_FUTURE)
        })
        it('should reject date with invalid digits in year', () => {
          const errors = validator.validateSync(new PaymentDate(new LocalDate(90, 12, 31)))

          expect(errors.length).to.equal(1)
          expectValidationError(errors, LocalDateValidationErrors.YEAR_FORMAT_NOT_VALID)
        })
 it('should return error when address is undefined', () => {
   individualDetails.address = undefined
   let errors: ValidationError[] = validator.validateSync(individualDetails)
   expectValidationError(errors, PartyDetailsValidationErrors.ADDRESS_REQUIRED)
 })
 it('should return errors when required address fields are missing', () => {
   let errors: ValidationError[] = validator.validateSync(individualDetails)
   expectValidationError(errors, AddressValidationErrors.FIRST_LINE_REQUIRED)
   expectValidationError(errors, AddressValidationErrors.POSTCODE_REQUIRED)
 })
 it('should return error when correspondence address is undefined', () => {
   individualDetails.correspondenceAddress = undefined
   let errors: ValidationError[] = validator.validateSync(individualDetails)
   expectValidationError(errors, PartyDetailsValidationErrors.CORRESPONDENCE_ADDRESS_REQUIRED)
 })
 it('should return no errors when correspondence address is provided', () => {
   individualDetails.correspondenceAddress = validAddress
   expect(validator.validateSync(individualDetails).length).to.equal(0)
 })
 it('should return error when dataOfBirth is null', () => {
   individualDetails.dateOfBirth = null
   let errors: ValidationError[] = validator.validateSync(individualDetails)
   expectValidationError(errors, PartyDetailsValidationErrors.NAME_REQUIRED)
 })
 private static isSectionValid (section): boolean {
   return !!section && validator.validateSync(section).length === 0
 }
 it('should return no errors when correspondence address is not provided', () => {
   partyDetails.address = validAddress
   partyDetails.hasCorrespondenceAddress = false
   partyDetails.name = 'claimantName'
   expect(validator.validateSync(partyDetails).length).to.equal(0)
 })
      it('no rows given, no comment', () => {
        const errors = validator.validateSync(new DefendantTimeline([]))

        expect(errors.length).to.equal(0)
      })
function isValid (input): boolean {
  return input !== undefined && validator.validateSync(input).length === 0
}
Example #17
0
      it('valid input', () => {
        const errors = validator.validateSync(new PaymentDate().deserialize(validDateInTheFutureObj))

        expect(errors.length).to.equal(0)
      })
function isValid (input): boolean {
  return !!input && validator.validateSync(input).length === 0
}
Example #19
0
        it('should reject non existing date', () => {
          const errors = validator.validateSync(new PaymentDate(new LocalDate(2017, 2, 29)))

          expect(errors.length).to.equal(1)
          expectValidationError(errors, ValidationErrors.DATE_NOT_VALID)
        })
    it('should reject expert required with no expert required option ', () => {
      const errors = validator.validateSync(new ExpertRequired())

      expect(errors).to.not.be.empty
      expectValidationError(errors, GlobalValidationErrors.YES_NO_REQUIRED)
    })
    it('Should reject an undefined option', () => {
      const errors = validator.validateSync(new PartPaymentReceived(undefined))

      expect(errors).to.be.length(1)
      expectValidationError(errors, ValidationErrors.YES_NO_REQUIRED)
    })
 it('should accept expert required with option present', () => {
   const errors = validator.validateSync(new ExpertRequired(YesNoOption.YES))
   expect(errors).to.be.empty
 })
      it('undefined option', () => {
        const errors = validator.validateSync(new PaymentOption(undefined))

        expect(errors.length).to.equal(1)
        expectValidationError(errors, ValidationErrors.OPTION_REQUIRED)
      })
    it('should reject InterestDate with undefined type', () => {
      const errors = validator.validateSync(new InterestDate(undefined))

      expect(errors.length).to.equal(1)
      expectValidationError(errors, ValidationErrors.TYPE_REQUIRED)
    })
        PaymentType.all().forEach(type => {
          const errors = validator.validateSync(new PaymentOption(type))

          expect(errors.length).to.equal(0)
        })
      InterestDateType.all().forEach(type => {
        const errors = validator.validateSync(new InterestDate(type))

        expect(errors.length).to.equal(0)
      })
      InterestEndDateOption.all().forEach(option => {
        const errors = validator.validateSync(new InterestEndDate(option))

        expect(errors.length).to.equal(0)
      })
      it('an invalid row given', () => {
        const errors = validator.validateSync(new DefendantTimeline([row('', 'ok')], ''))

        expect(errors.length).to.equal(1)
        expectValidationError(errors, ValidationErrors.DATE_REQUIRED)
      })
Example #29
0
      it('when valid type given and undefined description', () => {
        const errors = validator.validateSync(new EvidenceRow(EvidenceType.OTHER, undefined))

        expect(errors.length).to.equal(0)
      })
 it('should return errors when correspondence address required fields are missing', () => {
   let errors: ValidationError[] = validator.validateSync(partyDetails)
   expectValidationError(errors, CorrespondenceAddressValidationErrors.FIRST_LINE_REQUIRED)
   expectValidationError(errors, CorrespondenceAddressValidationErrors.CITY_REQUIRED)
   expectValidationError(errors, CorrespondenceAddressValidationErrors.POSTCODE_REQUIRED)
 })