Skip to content

Commit

Permalink
general cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
drkameleon committed Sep 12, 2024
1 parent e9bdd0e commit c8e73c9
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 11 deletions.
2 changes: 2 additions & 0 deletions src/validator.art
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,12 @@ export module [
;; valid?.email ["my@email.com", "info@google.com"]
;; ; => true
;; }

inputs: (string? str)? -> @[str][
ensure -> is? [:string] str
str
]

loop \validators [name, validator][
if attr name [
options: \fetchParams validator\params
Expand Down
4 changes: 2 additions & 2 deletions src/validators/base58.art
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
;==========================================================
; Base-58 validation
;
; @file: src/plugins/base58.art
; @file: src/validators/base58.art
;==========================================================

define :base58Validator is :validator [
Expand All @@ -21,7 +21,6 @@ define :base58Validator is :validator [
isBase58: {/^[A-HJ-NP-Za-km-z1-9]+$/} ; See:
; https://github.com/validatorjs/validator.js/blob/master/src/lib/isBase58.js


;------------------
; methods
;------------------
Expand All @@ -47,4 +46,5 @@ define :base58Validator is :validator [
]
]
]

]
3 changes: 2 additions & 1 deletion src/validators/card.art
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
; based on:
; https://en.wikipedia.org/wiki/International_Bank_Account_Number
;
; @file: src/plugins/card.art
; @file: src/validators/card.art
;==========================================================

define :cardValidator is :validator [
Expand Down Expand Up @@ -128,4 +128,5 @@ define :cardValidator is :validator [
]
]
]

]
4 changes: 3 additions & 1 deletion src/validators/email.art
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
; based on RFC5322:
; https://datatracker.ietf.org/doc/html/rfc5322
;
; @file: src/plugins/email.art
; @file: src/validators/email.art
;==========================================================

define :emailValidator is :validator [
Expand All @@ -23,6 +23,7 @@ define :emailValidator is :validator [

; For the regex, see:
; https://stackoverflow.com/a/201378

isEmail: {/(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/}

;------------------
Expand Down Expand Up @@ -60,4 +61,5 @@ define :emailValidator is :validator [
]
]
]

]
3 changes: 2 additions & 1 deletion src/validators/floating.art
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
;==========================================================
; Floating validation
;
; @file: src/plugins/floating.art
; @file: src/validators/floating.art
;==========================================================


Expand Down Expand Up @@ -42,4 +42,5 @@ define :floatingValidator is :validator [
]
]
]

]
4 changes: 3 additions & 1 deletion src/validators/iban.art
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
; based on:
; https://en.wikipedia.org/wiki/International_Bank_Account_Number
;
; @file: src/plugins/iban.art
; @file: src/validators/iban.art
;==========================================================

define :ibanValidator is :validator [
Expand Down Expand Up @@ -110,6 +110,7 @@ define :ibanValidator is :validator [
]

; for use in the checksum validation

base36: (map 0..9 'x -> to :string x) ++
map 97..122 'x -> upper to :string to :char x

Expand Down Expand Up @@ -255,4 +256,5 @@ define :ibanValidator is :validator [
]
]
]

]
3 changes: 2 additions & 1 deletion src/validators/integer.art
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
;==========================================================
; Integer validation
;
; @file: src/plugins/integer.art
; @file: src/validators/integer.art
;==========================================================

define :integerValidator is :validator [
Expand Down Expand Up @@ -42,4 +42,5 @@ define :integerValidator is :validator [
]
]
]

]
5 changes: 3 additions & 2 deletions src/validators/ip.art
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
;==========================================================
; IP address validation
;
; @file: src/plugins/ip.art
; @file: src/validators/ip.art
;==========================================================

define :ipValidator is :validator [
Expand Down Expand Up @@ -46,7 +46,7 @@ define :ipValidator is :validator [
]

test: method [][
#[
#[
valid: [
"1.2.3.4"
"0.0.0.0"
Expand Down Expand Up @@ -85,4 +85,5 @@ define :ipValidator is :validator [
]
]
]

]
3 changes: 2 additions & 1 deletion src/validators/isbn.art
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
;==========================================================
; ISBN validation
;
; @file: src/plugins/isbn.art
; @file: src/validators/isbn.art
;==========================================================

define :isbnValidator is :validator [
Expand Down Expand Up @@ -87,4 +87,5 @@ define :isbnValidator is :validator [
]
]
]

]
4 changes: 3 additions & 1 deletion src/validators/url.art
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
;==========================================================
; URL validation
;
; @file: src/plugins/url.art
; @file: src/validators/url.art
;==========================================================

define :urlValidator is :validator [
Expand All @@ -20,6 +20,7 @@ define :urlValidator is :validator [

; For the regex, see:
; https://gist.github.com/davidhartsough/a125b5cef0721880e034e16b8899b842

isUrl: {/^(https?:\/\/)((?!-)(?!.*--)[a-zA-Z\-0-9]{1,63}(?<!-)\.)+[a-zA-Z]{2,63}(\/[^\s]*)?$/}

;------------------
Expand Down Expand Up @@ -125,4 +126,5 @@ define :urlValidator is :validator [
]
]
]

]

0 comments on commit c8e73c9

Please sign in to comment.