Skip to content

Latest commit

 

History

History
44 lines (36 loc) · 1.13 KB

hasAllProperties.md

File metadata and controls

44 lines (36 loc) · 1.13 KB

hasAllProperties

[DEPRECATED] use objectShouldHave instead

Check for every property one object must have to succeed validation.

Declaration

function hasAllProperties(obj: object, requiredProperties: string[]): boolean;

Tests

PASS  test/hasAllProperties.test.ts
 Validators > hasAllProperties
   when an object is passed with all required properties
     ✓ returns true (2ms)
     ✓ does not call console.error
   when an object is passed missing a required property
     ✓ returns false
     ✓ call console.error with a message containing missing property name (1ms)
   when an object is passed missing more than one required property
     ✓ returns false (1ms)
     ✓ call console.error with a message containing all missing properties names
   when an empty array is passed as requiredProperties
     ✓ returns true (1ms)

Usage example

export default {
  props: {
    myProp: {
      type: Object,
      required: true,
      validator: object => hasAllProperties(object, [
        'object', 'should', 'have', 'all', 'these', 'properties',
      ]),
  },
}