text: class FormField{constructor(){this.isValid=!0,this.errors=[],this.bindedElement={},this.otherValues={},this.validators=Array.from(arguments)}validate(){this.errors=[],this.validators.forEach(e=>{e(this)}),this.isValid=0===this.errors.length}bindElement(e){this.bindedElement=document.querySelector(`#${e}`)}get value(){return this.bindedElement.value}set value(e){this.bindedElement.value=e}clear(){this.value=""}}class FileField extends FormField{get value(){return this.bindedElement.files}set value(e){console.log("The value of a FileField can't be set")}}class FormHelper{constructor(e){this.preventSubmit=!0,this.form=e,this.formElement=document.querySelector(`#${this.form.id}`),delete e.id,this.setupFormFieldDatabBinding(),this.setupFormSubmit()}validateForm(){const e={};let t=!0;for(const r in this.form){const i=this.form[r];i.otherValues=e,e[r]=i.value,i.validate(),i.errors.length>0&&(t=!1)}return t}clearForm(){for(const e in this.form){this.form[e].clear()}}setupFormFieldDatabBinding(){for(const e in this.form){this.form[e].bindElement(e)}}setupFormSubmit(){this.formElement.onsubmit=(e=>{this.preventSubmit&&(e.preventDefault(),this.validateForm()?this.onValid():this.onInvalid())})}submitForm(){this.preventSubmit=!1,this.formElement.submit(),this.preventSubmit=!0}onValid(){console.log("The form is valid.")}onInvalid(){console.log("The form is NOT valid!")}}function isFilledIn(e){return t=>{const r=t.value;null!=r&&""!=r||addToErrors(t,"This field is required",e)}}function isEmail(e){return t=>{const r=t.value;/\S+@\S+\.\S+/.test(r)||addToErrors(t,"This needs to be a valid email",e)}}function isSameAs(e,t){return r=>{const i=r.value;i!==r.otherValues[e]&&addToErrors(r,`${i} is not the same is ${e}`,t)}}function minLength(e,t){return r=>{r.value.length<e&&addToErrors(r,`Requires a minimum length of ${length}`,t)}}function maxLength(e,t){return r=>{r.value.length>e&&addToErrors(r,`Exceeds the maximum length of ${length}`,t)}}function filesUploaded(e,t){return r=>{r.value.length!==e&&addToErrors(r,`There amount of files uploaded is not ${e}`,t)}}function wrapper(e,t){return r=>{e(r.value)||addToErrors(r,"Wrapped function returned not valid",t)}}function addToErrors(e,t,r){const i=r||t;e.errors.push(i)}