Enum iron_valid::Rule
[−]
[src]
pub enum Rule<'a> { Accepted, ActiveUrl, Alpha, AlphaDash, AlphaNumeric, Array, Between(isize, isize), Boolean, Confirmed, Different(&'static str), Digits(usize), DigitsBetween(usize, usize), Distinct, Email, Filled, In(Vec<Value>), InArray(&'static str), Integer, IpAddress, Json, Max(isize), Min(isize), NotIn(Vec<Value>), NotInArray(&'static str), Numeric, Present, Regex(&'static str), Required, RequiredIf(&'static str, Value), RequiredUnless(&'static str, Value), RequiredWith(Vec<&'static str>), RequiredWithAll(Vec<&'static str>), RequiredWithout(Vec<&'static str>), RequiredWithoutAll(Vec<&'static str>), Same(&'static str), Size(isize), String, Url, // some variants omitted }
Variants
Accepted
The field under validation must be yes
, on
, 1
, or true
.
This is useful for validating "Terms of Service" acceptance.
On success, will transform the input to a boolean true
.
ActiveUrl
The field under validation, if present, must be an active domain name.
Alpha
The field under validation must be entirely alphabetic characters.
This validator accepts Latin and international (Unicode) input.
AlphaDash
The field under validation may have alpha-numeric characters, as well as dashes and underscores.
This validator accepts Latin and international (Unicode) input.
AlphaNumeric
The field under validation must be entirely alpha-numeric characters.
This validator accepts Latin and international (Unicode) input.
Array
The field under validation, if present, must be an array.
Between(isize, isize)
The field under validation, if present, must have a size between the given min and max.
Strings, numerics, and files are evaluated in the same fashion as the Size
rule.
Boolean
The field under validation, if present, must be able to be cast as a boolean.
Accepted input are true
, false
, 1
, 0
, "1"
, and "0"
.
On success, will transform the input to a boolean true
or false
.
Confirmed
The field under validation must have a matching field of foo_confirmation
.
For example, if the field under validation is password
,
a matching password_confirmation
field must be present in the input.
Different(&'static str)
The field under validation must have a different value than field
.
Digits(usize)
The field under validation, if present, must be numeric and must have an exact length of value.
For negative numbers, the negative sign is not counted as a digit. For floating point numbers, the number of digits preceeding the decimal place is counted.
On success, will transform string input to a numeric type.
DigitsBetween(usize, usize)
The field under validation, if present, must have a length between the given min and max.
On success, will transform string input to a numeric type.
Distinct
When working with arrays, the field under validation must not have any duplicate values if it is present.
Email
The field under validation, if present, must be formatted as an e-mail address.
Filled
The field under validation must not be empty when it is present.
In(Vec<Value>)
The field under validation, if present, must be included in the given list of values.
InArray(&'static str)
The field under validation, if present, must exist in anotherfield
's values.
Integer
The field under validation, if present, must be an integer.
On success, will transform string input to a numeric type.
IpAddress
The field under validation, if present, must be an IP address.
Accepts both IPv4 and IPv6 addresses.
Json
The field under validation, if present, must be a valid JSON string.
Max(isize)
The field under validation, if present, must be less than or equal to a maximum value.
Strings, numerics, and files are evaluated in the same fashion as the Size
rule.
Min(isize)
The field under validation, if present, must have a minimum value.
Strings, numerics, and files are evaluated in the same fashion as the Size
rule.
NotIn(Vec<Value>)
The field under validation must not be included in the given list of values.
NotInArray(&'static str)
The field under validation must not exist in anotherfield
's values.
Numeric
The field under validation, if present, must be numeric.
On success, will transform string input to a numeric type.
Present
The field under validation must be present in the input data but can be empty.
Regex(&'static str)
The field under validation, if present, must match the given regular expression.
On success, will transform input to a string.
Required
The field under validation must be present in the input data and not empty. A field is considered "empty" if one of the following conditions are true:
The value is null.
The value is an empty string.
The value is an empty array or empty object.
RequiredIf(&'static str, Value)
The field under validation must be present if the anotherfield
field
is equal to any value
.
RequiredUnless(&'static str, Value)
The field under validation must be present unless the anotherfield
field
is equal to any value
.
RequiredWith(Vec<&'static str>)
The field under validation must be present only if any of the other specified fields are present.
RequiredWithAll(Vec<&'static str>)
The field under validation must be present only if all of the other specified fields are present.
RequiredWithout(Vec<&'static str>)
The field under validation must be present only when any of the other specified fields are not present.
RequiredWithoutAll(Vec<&'static str>)
The field under validation must be present only when all of the other specified fields are not present.
Same(&'static str)
The given field must match the field under validation.
Size(isize)
The field under validation must have a size matching the given value.
For string data, value corresponds to the number of characters.
For numeric data, value corresponds to a given integer value.
For files, size corresponds to the file size in kilobytes.
String
The field under validation, if present, must be a string.
Url
The field under validation, if present, must be formatted as a valid URL,
but does not need to resolve to a real website. The URL must contain the scheme
or else it will fail validation. For example, http://google.com
will
pass validation, but google.com
will fail validation.
Trait Implementations
impl<'a> Clone for Rule<'a>
[src]
fn clone(&self) -> Rule<'a>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more