Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Validator = class {
- min(content, min) {
- if(content === undefined || content == null) return false
- return content.length >= min
- }
- max(content, max) {
- if(content === undefined || content == null) return false
- return content.length <= max
- }
- email(content) {
- if(content === undefined) return false
- var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
- return re.test(String(content).toLowerCase());
- }
- phone(content) {
- if(content === undefined) return false
- var re = /^[0-9]{11}$/
- return re.test(String(content))
- }
- zipcode(content) {
- if(content === undefined) return false
- var re = /^[0-9]{2}-[0-9]{3}$/
- return re.test(String(content));
- }
- date(content) {
- if(content === undefined || content === null) return false
- return true
- }
- pin(content) {
- let pin = [
- 988745, 760673, 363838, 470007, 803040, 992605,
- 406271, 369719, 351539, 982549, 176947, 249669,
- 439939, 912752, 389829, 815523, 170655, 837044,
- 419885, 522623, 483999, 209081, 725707, 527000,
- 364304, 631566, 542315, 482296, 742676, 342553,
- 340725, 708021, 915772, 106195, 141340, 598094,
- 212395, 983458, 828614, 806511
- ]
- if(pin.indexOf(parseInt(content)) === -1) return false
- return true
- }
- }
- const Errors = class {
- min(min) {
- return "To pole wymaga minimum " + min + " znaków"
- }
- max(max) {
- return "To pole może mieć maksymalnie " + max + " znaków"
- }
- email() {
- return "Niepoprawny adres email"
- }
- phone() {
- return "Niepoprawny numer telefonu"
- }
- zipcode() {
- return "Niepoprawny kod pocztowy"
- }
- date() {
- return "Niepoprawna data"
- }
- pin() {
- return "Niepoprawny numer pin"
- }
- }
- export {
- Validator,
- Errors,
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement