l.nullValue()
Passes only when the value is null. Returns a NullValidator, which has withName() and nothing else: a required value can never be null, and a custom validator would never be called.
Signature
Section titled “Signature”NullValidator nullValue({String? message, MessageBuilder? messageBuilder})Parameters
Section titled “Parameters”| Parameter | Type | Meaning |
|---|---|---|
message |
String? |
Replaces the default error message. |
messageBuilder |
MessageBuilder? |
Builds the message from the issue. message wins when both are given. See Message builders. |
Code invalidType. Default message: value must be null. value is replaced by the field name when there is one.
Code generation
Section titled “Code generation”A parameter of type Null maps to l.nullValue(). json_serializable and freezed cannot serialize a Null-typed field, so use it with dart_mappable or a hand-written fromJson. @WithCustomValidator on a Null field fails generation.
Example
Section titled “Example”final cleared = l.nullValue();Null? deletedAt, // l.nullValue()cleared.validate(input)+1-1- valid:
null - invalid:
1