1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.

/// <p>Validation rules for a text field.</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct TextValidation {
    /// <p>The minimum number of characters for the text field.</p>
    pub min_length: i32,
    /// <p>The maximum number of characters for the text field.</p>
    pub max_length: i32,
    /// <p>The regular expression used to validate the text field.</p>
    pub pattern: ::std::string::String,
}
impl TextValidation {
    /// <p>The minimum number of characters for the text field.</p>
    pub fn min_length(&self) -> i32 {
        self.min_length
    }
    /// <p>The maximum number of characters for the text field.</p>
    pub fn max_length(&self) -> i32 {
        self.max_length
    }
    /// <p>The regular expression used to validate the text field.</p>
    pub fn pattern(&self) -> &str {
        use std::ops::Deref;
        self.pattern.deref()
    }
}
impl TextValidation {
    /// Creates a new builder-style object to manufacture [`TextValidation`](crate::types::TextValidation).
    pub fn builder() -> crate::types::builders::TextValidationBuilder {
        crate::types::builders::TextValidationBuilder::default()
    }
}

/// A builder for [`TextValidation`](crate::types::TextValidation).
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
pub struct TextValidationBuilder {
    pub(crate) min_length: ::std::option::Option<i32>,
    pub(crate) max_length: ::std::option::Option<i32>,
    pub(crate) pattern: ::std::option::Option<::std::string::String>,
}
impl TextValidationBuilder {
    /// <p>The minimum number of characters for the text field.</p>
    /// This field is required.
    pub fn min_length(mut self, input: i32) -> Self {
        self.min_length = ::std::option::Option::Some(input);
        self
    }
    /// <p>The minimum number of characters for the text field.</p>
    pub fn set_min_length(mut self, input: ::std::option::Option<i32>) -> Self {
        self.min_length = input;
        self
    }
    /// <p>The minimum number of characters for the text field.</p>
    pub fn get_min_length(&self) -> &::std::option::Option<i32> {
        &self.min_length
    }
    /// <p>The maximum number of characters for the text field.</p>
    /// This field is required.
    pub fn max_length(mut self, input: i32) -> Self {
        self.max_length = ::std::option::Option::Some(input);
        self
    }
    /// <p>The maximum number of characters for the text field.</p>
    pub fn set_max_length(mut self, input: ::std::option::Option<i32>) -> Self {
        self.max_length = input;
        self
    }
    /// <p>The maximum number of characters for the text field.</p>
    pub fn get_max_length(&self) -> &::std::option::Option<i32> {
        &self.max_length
    }
    /// <p>The regular expression used to validate the text field.</p>
    /// This field is required.
    pub fn pattern(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.pattern = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>The regular expression used to validate the text field.</p>
    pub fn set_pattern(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.pattern = input;
        self
    }
    /// <p>The regular expression used to validate the text field.</p>
    pub fn get_pattern(&self) -> &::std::option::Option<::std::string::String> {
        &self.pattern
    }
    /// Consumes the builder and constructs a [`TextValidation`](crate::types::TextValidation).
    /// This method will fail if any of the following fields are not set:
    /// - [`min_length`](crate::types::builders::TextValidationBuilder::min_length)
    /// - [`max_length`](crate::types::builders::TextValidationBuilder::max_length)
    /// - [`pattern`](crate::types::builders::TextValidationBuilder::pattern)
    pub fn build(self) -> ::std::result::Result<crate::types::TextValidation, ::aws_smithy_types::error::operation::BuildError> {
        ::std::result::Result::Ok(crate::types::TextValidation {
            min_length: self.min_length.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "min_length",
                    "min_length was not specified but it is required when building TextValidation",
                )
            })?,
            max_length: self.max_length.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "max_length",
                    "max_length was not specified but it is required when building TextValidation",
                )
            })?,
            pattern: self.pattern.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "pattern",
                    "pattern was not specified but it is required when building TextValidation",
                )
            })?,
        })
    }
}