bevy_ui_builders/validation/
types.rs1use bevy::prelude::*;
4use crate::ValidationRule;
5
6#[derive(Component, Debug, Clone)]
8pub struct Validated {
9 pub rules: Vec<ValidationRule>,
11}
12
13impl Validated {
14 pub fn new(rules: Vec<ValidationRule>) -> Self {
16 Self { rules }
17 }
18}
19
20#[derive(Component, Debug, Clone)]
22pub struct ValidationState {
23 pub is_valid: bool,
25 pub error_message: Option<String>,
27}
28
29impl Default for ValidationState {
30 fn default() -> Self {
31 Self {
32 is_valid: true,
33 error_message: None,
34 }
35 }
36}
37
38impl ValidationState {
39 pub fn valid() -> Self {
41 Self {
42 is_valid: true,
43 error_message: None,
44 }
45 }
46
47 pub fn invalid(message: String) -> Self {
49 Self {
50 is_valid: false,
51 error_message: Some(message),
52 }
53 }
54}