Sindre Sorhus 7 years ago
committed by GitHub
parent
commit
6b179a037a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      package.json
  2. 1
      source/lib/predicates/boolean.ts
  3. 1
      source/lib/predicates/number.ts
  4. 5
      source/lib/predicates/predicate.ts
  5. 1
      source/lib/predicates/string.ts
  6. 5
      tslint.json

2
package.json

@ -55,7 +55,7 @@
"del-cli": "^1.1.0", "del-cli": "^1.1.0",
"nyc": "^11.2.1", "nyc": "^11.2.1",
"tslint": "^5.8.0", "tslint": "^5.8.0",
"tslint-xo": "^0.1.0", "tslint-xo": "^0.2.0",
"typescript": "^2.6.1" "typescript": "^2.6.1"
} }
} }

1
source/lib/predicates/boolean.ts

@ -1,7 +1,6 @@
import {Predicate, Context} from './predicate'; import {Predicate, Context} from './predicate';
export class BooleanPredicate extends Predicate<boolean> { export class BooleanPredicate extends Predicate<boolean> {
constructor(context?: Context) { constructor(context?: Context) {
super('boolean', context); super('boolean', context);
} }

1
source/lib/predicates/number.ts

@ -2,7 +2,6 @@ import * as is from '@sindresorhus/is';
import {Predicate, Context} from './predicate'; import {Predicate, Context} from './predicate';
export class NumberPredicate extends Predicate<number> { export class NumberPredicate extends Predicate<number> {
constructor(context?: Context) { constructor(context?: Context) {
super('number', context); super('number', context);
} }

5
source/lib/predicates/predicate.ts

@ -13,10 +13,11 @@ export interface Context {
export const validatorSymbol = Symbol('validators'); export const validatorSymbol = Symbol('validators');
export abstract class Predicate<T = any> { export abstract class Predicate<T = any> {
constructor( constructor(
type: string, type: string,
private context: Context = { validators: [] } private context: Context = {
validators: []
}
) { ) {
this.addValidator({ this.addValidator({
message: value => `Expected argument to be of type \`${type}\` but received type \`${is(value)}\``, message: value => `Expected argument to be of type \`${type}\` but received type \`${is(value)}\``,

1
source/lib/predicates/string.ts

@ -2,7 +2,6 @@ import * as valiDate from 'vali-date';
import {Predicate, Context} from './predicate'; import {Predicate, Context} from './predicate';
export class StringPredicate extends Predicate<string> { export class StringPredicate extends Predicate<string> {
constructor(context?: Context) { constructor(context?: Context) {
super('string', context); super('string', context);
} }

5
tslint.json

@ -1,3 +1,6 @@
{ {
"extends": "tslint-xo" "extends": "tslint-xo",
"rules": {
"completed-docs": [true, "methods"]
}
} }

Loading…
Cancel
Save