Closed dnish closed 3 years ago
Validators were designed as integral part of the package but probably shouldn't. There were some not great design decisions but it's still possible to call validators manually:
Astro.Validator.validators.date.isValid({ value: new Date() }); // true
Astro.Validator.validators.date.isValid({ value: 5 }); // false
Astro.Validator.validators.gte.isValid({ value: 10, param: 5 }); // true
You can go into code of each validator and see how the isValid
function is being executed for each validator.
Hey, I'm using some third party libraries on the client side and need to validate the forms based on the logic of the model. Is there any way to use the validators without creating a model? I've tried to check out the Validators class but it seems that it is heavily connected to the Model.
Normally I create a temporary model, add the form input to its properties and then execute a validation. But in this case it's a little bit problematic, because I want also to validate the password length - and the model doesn't have a password property (because it is saved within the services object).