wip
This commit is contained in:
@@ -53,8 +53,16 @@ class QueryCore implements Query {
|
||||
this.error = null;
|
||||
}
|
||||
|
||||
get isUndefined() {
|
||||
return this.value === undefined;
|
||||
}
|
||||
|
||||
get isNull() {
|
||||
return this.value === null;
|
||||
}
|
||||
|
||||
get isEmpty() {
|
||||
return this.value === undefined || this.value === null;
|
||||
return this.isUndefined || this.isNull;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,7 +73,7 @@ class QueryCore implements Query {
|
||||
}
|
||||
|
||||
/**
|
||||
* このインスタンスの値が空の場合エラーにします
|
||||
* このインスタンスの値が空のときにエラーにします
|
||||
*/
|
||||
required() {
|
||||
if (this.error === null && this.isEmpty) {
|
||||
@@ -75,10 +83,30 @@ class QueryCore implements Query {
|
||||
}
|
||||
|
||||
/**
|
||||
* このインスタンスの値が設定されていないときにデフォルトで設定する値を設定します
|
||||
* このインスタンスの値が設定されていない(=undefined)場合エラーにします
|
||||
*/
|
||||
notUndefined() {
|
||||
if (this.error === null && this.isUndefined) {
|
||||
this.error = new Error('required');
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* このインスタンスの値が null のときにエラーにします
|
||||
*/
|
||||
notNull() {
|
||||
if (this.error === null && this.isNull) {
|
||||
this.error = new Error('required');
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* このインスタンスの値が設定されていない(=undefined)ときにデフォルトで設定する値を設定します
|
||||
*/
|
||||
default(value: any) {
|
||||
if (this.isEmpty) {
|
||||
if (this.isUndefined) {
|
||||
this.value = value;
|
||||
}
|
||||
return this;
|
||||
@@ -119,13 +147,6 @@ class BooleanQuery extends QueryCore {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* このインスタンスの値が undefined または null の場合エラーにします
|
||||
*/
|
||||
required() {
|
||||
return super.required();
|
||||
}
|
||||
|
||||
/**
|
||||
* このインスタンスの値が設定されていないときにデフォルトで設定する値を設定します
|
||||
*/
|
||||
@@ -198,13 +219,6 @@ class NumberQuery extends QueryCore {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* このインスタンスの値が undefined または null の場合エラーにします
|
||||
*/
|
||||
required() {
|
||||
return super.required();
|
||||
}
|
||||
|
||||
/**
|
||||
* このインスタンスの値が設定されていないときにデフォルトで設定する値を設定します
|
||||
*/
|
||||
@@ -259,13 +273,6 @@ class StringQuery extends QueryCore {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* このインスタンスの値が undefined または null の場合エラーにします
|
||||
*/
|
||||
required() {
|
||||
return super.required();
|
||||
}
|
||||
|
||||
/**
|
||||
* このインスタンスの値が設定されていないときにデフォルトで設定する値を設定します
|
||||
*/
|
||||
@@ -361,13 +368,6 @@ class ArrayQuery extends QueryCore {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* このインスタンスの値が undefined または null の場合エラーにします
|
||||
*/
|
||||
required() {
|
||||
return super.required();
|
||||
}
|
||||
|
||||
/**
|
||||
* このインスタンスの値が設定されていないときにデフォルトで設定する値を設定します
|
||||
*/
|
||||
@@ -403,13 +403,6 @@ class IdQuery extends QueryCore {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* このインスタンスの値が undefined または null の場合エラーにします
|
||||
*/
|
||||
required() {
|
||||
return super.required();
|
||||
}
|
||||
|
||||
/**
|
||||
* このインスタンスの値が設定されていないときにデフォルトで設定する値を設定します
|
||||
*/
|
||||
@@ -445,13 +438,6 @@ class ObjectQuery extends QueryCore {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* このインスタンスの値が undefined または null の場合エラーにします
|
||||
*/
|
||||
required() {
|
||||
return super.required();
|
||||
}
|
||||
|
||||
/**
|
||||
* このインスタンスの値が設定されていないときにデフォルトで設定する値を設定します
|
||||
*/
|
||||
|
Reference in New Issue
Block a user