Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ArrayType.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class ArrayType extends Type {
* )
*/
of(type, errorMessage) {
this.ofType = type;
super.pushRule(items => {
let valids = items.map(value => type.check(value));
let errors = valids.filter(item => item.hasError) || [];
Expand Down
1 change: 1 addition & 0 deletions src/ObjectType.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class ObjectType extends Type {
* })
*/
shape(types) {
this.shapeType = types;
super.pushRule(values => {
let valids = Object.entries(types).map(item => {
let key = item[0];
Expand Down
1 change: 1 addition & 0 deletions types/ArrayType.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Type } from './Type';

export declare class ArrayType<ValueType = any, DataType = any, ErrorMsgType = string> extends Type<ValueType, DataType, ErrorMsgType> {
readonly name: 'array';
readonly ofType: CheckType<ValueType, DataType, ErrorMsgType>;
constructor(errorMessage?: ErrorMsgType);
rangeLength: (minLength: number, maxLength: number, errorMessage?: ErrorMsgType) => this;
minLength: (minLength: number, errorMessage?: ErrorMsgType) => this;
Expand Down
1 change: 1 addition & 0 deletions types/ObjectType.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Type } from './Type';

export declare class ObjectType<ValueType = any, DataType = any, ErrorMsgType = string> extends Type<ValueType, DataType, ErrorMsgType> {
readonly name: 'object';
readonly shapeType: SchemaDeclaration<ValueType, ErrorMsgType>;
constructor(errorMessage?: ErrorMsgType);
shape: (types: SchemaDeclaration<ValueType, ErrorMsgType>) => this;
}
Expand Down