Options
All
  • Public
  • Public/Protected
  • All
Menu

Class SetPredicate<T>

Type parameters

  • T = any

Hierarchy

  • Predicate<Set<T>>
    • SetPredicate

Index

Constructors

constructor

constructor:

Accessors

empty

  • get empty(): this

nonEmpty

  • get nonEmpty(): this

not

  • get not(): this

Methods

Protected addValidator

  • addValidator(validator: Validator<Set<T>>): SetPredicate<T>

deepEqual

has

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

    Parameters

    • Rest ...items: readonly T[]

      The items that should be a item in the Set.

    Returns SetPredicate<T>

hasAny

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

    Parameters

    • Rest ...items: readonly T[]

      The items that could be a item in the Set.

    Returns SetPredicate<T>

is

  • is(validator: (value: Set<T>) => string | boolean): SetPredicate<T>
  • 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: Set<T>) => string | boolean

      Validation function.

        • (value: Set<T>): string | boolean
        • Parameters

          • value: Set<T>

          Returns string | boolean

    Returns SetPredicate<T>

maxSize

message

  • message(newMessage: string | ValidatorMessageBuilder<Set<T>>): SetPredicate<T>
  • 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<Set<T>>

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

    Returns SetPredicate<T>

minSize

ofType

  • Test all the items in the Set to match the provided predicate.

    Parameters

    • predicate: Predicate<T>

      The predicate that should be applied against every item in the Set.

    Returns SetPredicate<T>

size

validate

  • validate(customValidator: CustomValidator<Set<T>>): SetPredicate<T>
  • 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<Set<T>>

      Custom validation function.

    Returns SetPredicate<T>