# cp.rx.go.Require

A Statement that will require that the resolvable value matches a predicate, and if not, it will send an error.


# Submodules


# API Overview

Constants - Useful values which cannot be changed

  • OrThrow

Functions - API calls offered directly by the extension

  • Require

Methods - API calls which can only be made on an object returned by a constructor

  • Are
  • AreNot
  • Is
  • IsNot
  • Matches
  • OrThrow

# API Documentation

# Constants

# OrThrow

Signature cp.rx.go.Require.OrThrow <cp.rx.go.Statement.Modifier>
Type Constant
Description A Statement.Modifier that sets the message to throw if the requirement is not met.
Notes None
Source src/extensions/cp/rx/go/Require.lua line 59

# Functions

# Require

Signature cp.rx.go.Require(requirement) -> Require
Type Function
Description Creates a new Require Statement with the specified requirement.
Parameters
  • requirement - a resolvable value that will be checked.
Returns
  • The Statement instance which will check if the requirement matches the requirement.
Notes
  • By default, it will require that all items in the requirement are not nil and completed.
  • This is most useful with Given, allowing retrieval and checking of values before continuing.
  • Example:
  • lua</li><li>Given(</li><li> Require(someObservable):Is(2):OrThrow("Must be 2")</li><li>):Then(function(someValue)</li><li> -- do stuff with `someValue`</li><li>):Now()</li><li>
Examples None
Source src/extensions/cp/rx/go/Require.lua line 16

# Methods

# Are

Signature cp.rx.go.Require:Are(value) -> Require.Are
Type Method
Description Specifies the value to check.
Parameters
  • value - The value that all results from the requirement must match.
Returns
  • The Are Statement.Modifier.
Notes None
Examples None
Source src/extensions/cp/rx/go/Require.lua line 105

# AreNot

Signature cp.rx.go.Require:AreNot(value) -> Require.AreNot
Type Method
Description Specifies the value to check.
Parameters
  • value - The value that all results from the requirement must match.
Returns
  • The AreNot Statement.Modifier.
Notes None
Examples None
Source src/extensions/cp/rx/go/Require.lua line 170

# Is

Signature cp.rx.go.Require:Is(value) -> Require.Is
Type Method
Description Specifies the value to check.
Parameters
  • value - The value that all results from the requirement must match.
Returns
  • The Is Statement.Modifier.
Notes None
Examples None
Source src/extensions/cp/rx/go/Require.lua line 87

# IsNot

Signature cp.rx.go.Require:IsNot(value) -> Require.IsNot
Type Method
Description Specifies the value to check.
Parameters
  • value - The value that all results from the requirement must not match.
Returns
  • The IsNot Statement.Modifier.
Notes None
Examples None
Source src/extensions/cp/rx/go/Require.lua line 152

# Matches

Signature cp.rx.go.Require:Matches(predicate) -> Require.Matches
Type Method
Description Specifies the predicate to check.
Parameters
  • value - The value that all results from the requirement must not match.
Returns
  • The Matches Statement.Modifier.
Notes
  • Example:
  • lua</li><li>Require(someObservable):Matches(function(value) return value % 2 == 0 end)</li><li>
Examples None
Source src/extensions/cp/rx/go/Require.lua line 217

# OrThrow

Signature cp.rx.go.Require:OrThrow(message) -> Require.OrThrow
Type Method
Description Specifies the message to throw if the requirement is not met.
Parameters
  • message - The string to throw when there is an error.
Returns
  • The OrThrow Statement.Modifier.
Notes None
Examples None
Source src/extensions/cp/rx/go/Require.lua line 63