fn render(&self) -> String;
+ fn validate(&self) -> String;
+
fn any(&mut self) -> &mut dyn Any;
}
+fn validate_std(f: &Field) -> String {
+ let mut s = String::from("<ul>\n");
+
+ for v in &f.validators {
+ let msg = v.validate(&f.value);
+ if msg != "" {
+ s.push_str(format!("<li>{}</li>\n", &msg).as_str());
+ }
+ }
+
+ s.push_str("</ul>");
+
+ s
+}
+
#[derive(Default)]
pub struct FieldText {
field: Field,
s
}
+ fn validate(&self) -> String {
+ validate_std(&self.field)
+ }
+
fn any(&mut self) -> &mut dyn Any {
self
}
s
}
+ fn validate(&self) -> String {
+ validate_std(&self.field)
+ }
+
fn any(&mut self) -> &mut dyn Any {
self
}
s
}
+ fn validate(&self) -> String {
+ validate_std(&self.field)
+ }
+
fn any(&mut self) -> &mut dyn Any {
self
}
s
}
+ fn validate(&self) -> String {
+ validate_std(&self.field)
+ }
+
fn any(&mut self) -> &mut dyn Any {
self
}
s
}
+ fn validate(&self) -> String {
+ validate_std(&self.field)
+ }
+
fn any(&mut self) -> &mut dyn Any {
self
}
s
}
+ fn validate(&self) -> String {
+ validate_std(&self.field)
+ }
+
fn any(&mut self) -> &mut dyn Any {
self
}
fn get_message(&self) -> String;
fn set_message(&mut self, message: &str);
- fn validate(&self, value: &String) -> bool;
+ fn validate(&self, value: &String) -> String;
}
#[derive(Default)]
self.validator.message = String::from(message);
}
- fn validate(&self, value: &String) -> bool {
+ fn validate(&self, value: &String) -> String {
if value != "" {
- true
+ self.get_message()
} else {
- false
+ String::from("")
}
}
}
self.validator.message = String::from(message);
}
- fn validate(&self, value: &String) -> bool {
- true
+ fn validate(&self, value: &String) -> String {
+ String::from("")
}
}