Required
Validation that checks that a value is not missing (this checks that the value is not null, false, or empty). This validation checks the emptiness of values of type String, Collection, Array (and variants), Map, and Table.
When the value being validated is missing, then an issue is emitted with the provided code (defaults to DEFAULT_CODE).
A few notes on the Required validation:
This validation tries to match the expected notion of what it means for a value to be "required": this can be thought of as the (∗) icon typically shown in user interfaces to denote required fields.
If a value is not nullable, and you want to forbid it from being empty, this validation should be preferred over NotEmpty since it is the semantic way of signalling that the value is required (even though both validations would acchieve the same result).
When a value is nullable and
nullvalues are not to be allowed, then this validation must be set on the NullableSchema itself, rather than on its inner schema.Custom validations may use the isMissing/isNotMissing functions to match the notion of "missing" values used by this validation.
Empty files (files with size 0) are not considered missing values. This is due to the fact that empty files still contain some information (the file name itself) and is consistent with how empty files are treated in web forms. To forbid both the
nullvalue and empty files, use Required together with NotEmpty.To only validate that a value is not
nullorfalse, use MustNotEqual instead.To allow
nullbut not empty values, use NotEmpty instead.To prevent both empty and blank strings, use Required together with NotBlank.
Parameters
Issue code to use when the value is missing.
Severity of the issue emitted when the value is missing.
Constructors
Properties
Dependencies of the validation. Mapping of keys to the paths this validation depends on. Keys can be used within a ValidationContext to access the value of the dependencies.
Whether the form manager should reevaluate this validation whenever a descendant of the value being validated changes. This is false by default.
Set of external context dependencies of the validation.
Functions
Runs the validation within a ValidationContext containing the value being validated and the value of all declared dependencies. Returns a flow over all found issues.