lib/types: Fix coercedTo check
Without this change
(coercedTo str toInt int).check "foo"
would evaluate to true, even though
(coercedTo str toInt int).merge {} [{ value = "foo"; }]
will throw an error because "foo" can't be coerced to an int.
This commit is contained in:
committed by
Profpatsch
parent
85b5fc7c98
commit
ef8996f15e
+1
-1
@@ -420,7 +420,7 @@ rec {
|
|||||||
mkOptionType rec {
|
mkOptionType rec {
|
||||||
name = "coercedTo";
|
name = "coercedTo";
|
||||||
description = "${finalType.description} or ${coercedType.description}";
|
description = "${finalType.description} or ${coercedType.description}";
|
||||||
check = x: finalType.check x || coercedType.check x;
|
check = x: finalType.check x || (coercedType.check x && finalType.check (coerceFunc x));
|
||||||
merge = loc: defs:
|
merge = loc: defs:
|
||||||
let
|
let
|
||||||
coerceVal = val:
|
coerceVal = val:
|
||||||
|
|||||||
Reference in New Issue
Block a user