@@ -28,25 +28,25 @@ export const IPV6_FORMAT =
2828 '^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$' ;
2929export const HEX_FORMAT = '^[0-9a-fA-F]+$' ;
3030
31- export interface Matcher < T > {
31+ export interface MatcherV2 < T > {
3232 value ?: T ;
3333 'pact:matcher:type' : string ;
3434 getValue ( ) : T ;
3535}
3636
37- export interface ArrayMatcher < T > extends Matcher < T > {
37+ export interface ArrayMatcher < T > extends MatcherV2 < T > {
3838 'pact:matcher:type' : string ;
3939 min ?: number ;
4040 max ?: number ;
4141}
4242
43- export function isMatcher ( x : unknown ) : x is Matcher < AnyTemplate > {
44- return x != null && ( x as Matcher < AnyTemplate > ) . getValue !== undefined ;
43+ export function isMatcher ( x : unknown ) : x is MatcherV2 < AnyTemplate > {
44+ return x != null && ( x as MatcherV2 < AnyTemplate > ) . getValue !== undefined ;
4545}
4646
4747export type AnyTemplate =
4848 | AnyJson
49- | Matcher < AnyTemplate >
49+ | MatcherV2 < AnyTemplate >
5050 | ArrayMatcher < AnyTemplate >
5151 | TemplateMap
5252 | ArrayTemplate ;
@@ -105,7 +105,7 @@ export function eachLike<T>(
105105 * The somethingLike matcher
106106 * @param {any } value - the value to be somethingLike
107107 */
108- export function somethingLike < T > ( value : T ) : Matcher < T > {
108+ export function somethingLike < T > ( value : T ) : MatcherV2 < T > {
109109 if ( isNil ( value ) || isFunction ( value ) ) {
110110 throw new MatcherError (
111111 'Error creating a Pact somethingLike Match. Value cannot be a function or undefined'
@@ -119,7 +119,7 @@ export function somethingLike<T>(value: T): Matcher<T> {
119119 } ;
120120}
121121
122- export interface RegexMatcher < T > extends Matcher < T > {
122+ export interface RegexMatcher < T > extends MatcherV2 < T > {
123123 regex : string ;
124124}
125125
@@ -158,7 +158,7 @@ export function term(opts: {
158158 * Email address matcher.
159159 * @param {string } address - a email address to use as an example
160160 */
161- export function email ( address ?: string ) : Matcher < string > {
161+ export function email ( address ?: string ) : MatcherV2 < string > {
162162 return term ( {
163163 generate :
address || '[email protected] ' , 164164 matcher : EMAIL_FORMAT ,
@@ -169,7 +169,7 @@ export function email(address?: string): Matcher<string> {
169169 * UUID v4 matcher.
170170 * @param {string } id - a UUID to use as an example.
171171 */
172- export function uuid ( id ?: string ) : Matcher < string > {
172+ export function uuid ( id ?: string ) : MatcherV2 < string > {
173173 return term ( {
174174 generate : id || 'ce118b6e-d8e1-11e7-9296-cec278b6b50a' ,
175175 matcher : UUID_V4_FORMAT ,
@@ -180,7 +180,7 @@ export function uuid(id?: string): Matcher<string> {
180180 * IPv4 matcher.
181181 * @param {string } ip - an IPv4 address to use as an example. Defaults to `127.0.0.13`
182182 */
183- export function ipv4Address ( ip ?: string ) : Matcher < string > {
183+ export function ipv4Address ( ip ?: string ) : MatcherV2 < string > {
184184 return term ( {
185185 generate : ip || '127.0.0.13' ,
186186 matcher : IPV4_FORMAT ,
@@ -191,7 +191,7 @@ export function ipv4Address(ip?: string): Matcher<string> {
191191 * IPv6 matcher.
192192 * @param {string } ip - an IPv6 address to use as an example. Defaults to '::ffff:192.0.2.128'
193193 */
194- export function ipv6Address ( ip ?: string ) : Matcher < string > {
194+ export function ipv6Address ( ip ?: string ) : MatcherV2 < string > {
195195 return term ( {
196196 generate : ip || '::ffff:192.0.2.128' ,
197197 matcher : IPV6_FORMAT ,
@@ -203,7 +203,7 @@ export function ipv6Address(ip?: string): Matcher<string> {
203203 * @param {string } date - an ISO8601 Date and Time string
204204 * e.g. 2015-08-06T16:53:10+01:00 are valid
205205 */
206- export function iso8601DateTime ( date ?: string ) : Matcher < string > {
206+ export function iso8601DateTime ( date ?: string ) : MatcherV2 < string > {
207207 return term ( {
208208 generate : date || '2015-08-06T16:53:10+01:00' ,
209209 matcher : ISO8601_DATETIME_FORMAT ,
@@ -214,7 +214,7 @@ export function iso8601DateTime(date?: string): Matcher<string> {
214214 * ISO8601 DateTime matcher with required millisecond precision
215215 * @param {string } date - an ISO8601 Date and Time string, e.g. 2015-08-06T16:53:10.123+01:00
216216 */
217- export function iso8601DateTimeWithMillis ( date ?: string ) : Matcher < string > {
217+ export function iso8601DateTimeWithMillis ( date ?: string ) : MatcherV2 < string > {
218218 return term ( {
219219 generate : date || '2015-08-06T16:53:10.123+01:00' ,
220220 matcher : ISO8601_DATETIME_WITH_MILLIS_FORMAT ,
@@ -225,18 +225,18 @@ export function iso8601DateTimeWithMillis(date?: string): Matcher<string> {
225225 * ISO8601 Date matcher.
226226 * @param {string } date - a basic yyyy-MM-dd date string e.g. 2000-09-31
227227 */
228- export function iso8601Date ( date ?: string ) : Matcher < string > {
228+ export function iso8601Date ( date ?: string ) : MatcherV2 < string > {
229229 return term ( {
230230 generate : date || '2013-02-01' ,
231231 matcher : ISO8601_DATE_FORMAT ,
232232 } ) ;
233233}
234234
235235/**
236- * ISO8601 Time Matcher , matches a pattern of the format "'T'HH:mm:ss".
236+ * ISO8601 Time MatcherV2 , matches a pattern of the format "'T'HH:mm:ss".
237237 * @param {string } date - a ISO8601 formatted time string e.g. T22:44:30.652Z
238238 */
239- export function iso8601Time ( time ?: string ) : Matcher < string > {
239+ export function iso8601Time ( time ?: string ) : MatcherV2 < string > {
240240 return term ( {
241241 generate : time || 'T22:44:30.652Z' ,
242242 matcher : ISO8601_TIME_FORMAT ,
@@ -248,51 +248,51 @@ export function iso8601Time(time?: string): Matcher<string> {
248248 *
249249 * @param {string } date - an RFC1123 Date and Time string, e.g. Mon, 31 Oct 2016 15:21:41 -0400
250250 */
251- export function rfc1123Timestamp ( timestamp ?: string ) : Matcher < string > {
251+ export function rfc1123Timestamp ( timestamp ?: string ) : MatcherV2 < string > {
252252 return term ( {
253253 generate : timestamp || 'Mon, 31 Oct 2016 15:21:41 -0400' ,
254254 matcher : RFC1123_TIMESTAMP_FORMAT ,
255255 } ) ;
256256}
257257
258258/**
259- * Hexadecimal Matcher .
259+ * Hexadecimal MatcherV2 .
260260 * @param {string } hex - a hex value.
261261 */
262- export function hexadecimal ( hex ?: string ) : Matcher < string > {
262+ export function hexadecimal ( hex ?: string ) : MatcherV2 < string > {
263263 return term ( {
264264 generate : hex || '3F' ,
265265 matcher : HEX_FORMAT ,
266266 } ) ;
267267}
268268
269269/**
270- * Decimal Matcher .
270+ * Decimal MatcherV2 .
271271 * @param {float } float - a decimal value.
272272 */
273- export function decimal ( float ?: number ) : Matcher < number > {
273+ export function decimal ( float ?: number ) : MatcherV2 < number > {
274274 return somethingLike < number > ( isNil ( float ) ? 13.01 : float ) ;
275275}
276276
277277/**
278- * Integer Matcher .
278+ * Integer MatcherV2 .
279279 * @param {integer } int - an int value.
280280 */
281- export function integer ( int ?: number ) : Matcher < number > {
281+ export function integer ( int ?: number ) : MatcherV2 < number > {
282282 return somethingLike < number > ( isNil ( int ) ? 13 : int ) ;
283283}
284284
285285/**
286- * Boolean Matcher .
286+ * Boolean MatcherV2 .
287287 */
288- export function boolean ( value = true ) : Matcher < boolean > {
288+ export function boolean ( value = true ) : MatcherV2 < boolean > {
289289 return somethingLike < boolean > ( value ) ;
290290}
291291
292292/**
293- * String Matcher .
293+ * String MatcherV2 .
294294 */
295- export function string ( value = 'iloveorange' ) : Matcher < string > {
295+ export function string ( value = 'iloveorange' ) : MatcherV2 < string > {
296296 return somethingLike < string > ( value ) ;
297297}
298298
0 commit comments