|
// retoor <retoor@molodetz.nl>
|
|
|
|
import "wdantic" for Validator
|
|
|
|
System.print(Validator.email("test@example.com")) // expect: true
|
|
System.print(Validator.email("invalid")) // expect: false
|
|
System.print(Validator.email("test@domain")) // expect: false
|
|
|
|
System.print(Validator.domain("example.com")) // expect: true
|
|
System.print(Validator.domain("sub.example.com")) // expect: true
|
|
System.print(Validator.domain("-invalid.com")) // expect: false
|
|
|
|
System.print(Validator.safeStr("Hello World")) // expect: true
|
|
System.print(Validator.safeStr("Line1\nLine2")) // expect: false
|
|
|
|
System.print(Validator.url("https://example.com")) // expect: true
|
|
System.print(Validator.url("http://localhost:8080/path")) // expect: true
|
|
System.print(Validator.url("ftp://invalid")) // expect: false
|
|
|
|
System.print(Validator.uuid("550e8400-e29b-41d4-a716-446655440000")) // expect: true
|
|
System.print(Validator.uuid("invalid")) // expect: false
|
|
|
|
System.print(Validator.minLength("hello", 3)) // expect: true
|
|
System.print(Validator.minLength("hi", 3)) // expect: false
|
|
|
|
System.print(Validator.maxLength("hi", 5)) // expect: true
|
|
System.print(Validator.maxLength("hello world", 5)) // expect: false
|
|
|
|
System.print(Validator.range(5, 1, 10)) // expect: true
|
|
System.print(Validator.range(15, 1, 10)) // expect: false
|
|
|
|
System.print(Validator.positive(5)) // expect: true
|
|
System.print(Validator.positive(-5)) // expect: false
|
|
|
|
System.print(Validator.integer(5)) // expect: true
|
|
System.print(Validator.integer(5.5)) // expect: false
|