Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MapPredicate<T1, T2>

Type parameters

  • T1 = unknown

  • T2 = unknown

Hierarchy

  • Predicate<Map<T1, T2>>
    • MapPredicate

Index

Accessors

empty

  • get empty(): this

nonEmpty

  • get nonEmpty(): this

not

  • get not(): this

Methods

Protected addValidator

  • addValidator(validator: Validator<Map<T1, T2>>): MapPredicate<T1, T2>

deepEqual

hasAnyKeys

  • Test a Map to include any of the provided keys. The keys are tested by identity, not structure.

    Parameters

    • Rest ...keys: readonly T1[]

      The keys that could be a key in the Map.

    Returns MapPredicate<T1, T2>

hasAnyValues

  • hasAnyValues(...values: readonly T2[]): MapPredicate<T1, T2>
  • Test a Map to include any of the provided values. The values are tested by identity, not structure.

    Parameters

    • Rest ...values: readonly T2[]

      The values that could be a value in the Map.

    Returns MapPredicate<T1, T2>

hasKeys

  • Test a Map to include all the provided keys. The keys are tested by identity, not structure.

    Parameters

    • Rest ...keys: readonly T1[]

      The keys that should be a key in the Map.

    Returns MapPredicate<T1, T2>

hasValues

  • Test a Map to include all the provided values. The values are tested by identity, not structure.

    Parameters

    • Rest ...values: readonly T2[]

      The values that should be a value in the Map.

    Returns MapPredicate<T1, T2>

is

  • is(validator: (value: Map<T1, T2>) => string | boolean): MapPredicate<T1, T2>
  • Test if the value matches a custom validation function. The validation function should return true if the value passes the function. If the function either returns false or a string, the function fails and the string will be used as error message.

    Parameters

    • validator: (value: Map<T1, T2>) => string | boolean

      Validation function.

        • (value: Map<T1, T2>): string | boolean
        • Parameters

          • value: Map<T1, T2>

          Returns string | boolean

    Returns MapPredicate<T1, T2>

keysOfType

  • keysOfType(predicate: Predicate<T1>): MapPredicate<T1, T2>
  • Test all the keys in the Map to match the provided predicate.

    Parameters

    • predicate: Predicate<T1>

      The predicate that should be applied against every key in the Map.

    Returns MapPredicate<T1, T2>

maxSize

message

  • message(newMessage: string | ValidatorMessageBuilder<Map<T1, T2>>): MapPredicate<T1, T2>
  • Provide a new error message to be thrown when the validation fails.

    example
    ow('🌈', 'unicorn', ow.string.equals('🦄').message('Expected unicorn, got rainbow'));
    //=> ArgumentError: Expected unicorn, got rainbow
    
    example
    ow('🌈', ow.string.minLength(5).message((value, label) => `Expected ${label}, to have a minimum length of 5, got \`${value}\``));
    //=> ArgumentError: Expected string, to be have a minimum length of 5, got `🌈`
    

    Parameters

    • newMessage: string | ValidatorMessageBuilder<Map<T1, T2>>

      Either a string containing the new message or a function returning the new message.

    Returns MapPredicate<T1, T2>

minSize

size

validate

  • validate(customValidator: CustomValidator<Map<T1, T2>>): MapPredicate<T1, T2>
  • Test if the value matches a custom validation function. The validation function should return an object containing a validator and message. If the validator is false, the validation fails and the message will be used as error message. If the message is a function, the function is invoked with the label as argument to let you further customize the error message.

    Parameters

    • customValidator: CustomValidator<Map<T1, T2>>

      Custom validation function.

    Returns MapPredicate<T1, T2>

valuesOfType

  • valuesOfType(predicate: Predicate<T2>): MapPredicate<T1, T2>
  • Test all the values in the Map to match the provided predicate.

    Parameters

    • predicate: Predicate<T2>

      The predicate that should be applied against every value in the Map.

    Returns MapPredicate<T1, T2>