use js_sys::Object;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
pub struct ValidityState {
bad_input: bool,
custom_error: bool,
pattern_mismatch: bool,
range_overflow: bool,
range_underflow: bool,
too_long: bool,
too_short: bool,
type_mismatch: bool,
valid: bool,
value_missing: bool,
}
impl ValidityState {
pub fn new() -> Self {
Self {
bad_input: false,
custom_error: false,
pattern_mismatch: false,
range_overflow: false,
range_underflow: false,
too_long: false,
too_short: false,
type_mismatch: false,
valid: true,
value_missing: false,
}
}
pub fn bad_input(&self) -> bool {
self.bad_input
}
pub fn custom_error(&self) -> bool {
self.custom_error
}
pub fn pattern_mismatch(&self) -> bool {
self.pattern_mismatch
}
pub fn range_overflow(&self) -> bool {
self.range_overflow
}
pub fn range_underflow(&self) -> bool {
self.range_underflow
}
pub fn too_long(&self) -> bool {
self.too_long
}
pub fn too_short(&self) -> bool {
self.too_short
}
pub fn type_mismatch(&self) -> bool {
self.type_mismatch
}
pub fn valid(&self) -> bool {
self.valid
}
pub fn value_missing(&self) -> bool {
self.value_missing
}
pub fn set_bad_input(&mut self, value: bool) -> &mut Self {
self.bad_input = value;
self
}
pub fn set_custom_error(&mut self, value: bool) -> &mut Self {
self.custom_error = value;
self
}
pub fn set_pattern_mismatch(&mut self, value: bool) -> &mut Self {
self.pattern_mismatch = value;
self
}
pub fn set_range_overflow(&mut self, value: bool) -> &mut Self {
self.range_overflow = value;
self
}
pub fn set_range_underflow(&mut self, value: bool) -> &mut Self {
self.range_underflow = value;
self
}
pub fn set_too_long(&mut self, value: bool) -> &mut Self {
self.too_long = value;
self
}
pub fn set_too_short(&mut self, value: bool) -> &mut Self {
self.too_short = value;
self
}
pub fn set_type_mismatch(&mut self, value: bool) -> &mut Self {
self.type_mismatch = value;
self
}
pub fn set_valid(&mut self, value: bool) -> &mut Self {
self.valid = value;
self
}
pub fn set_value_missing(&mut self, value: bool) -> &mut Self {
self.value_missing = value;
self
}
}
impl Default for ValidityState {
fn default() -> Self {
Self::new()
}
}