@@ -23,11 +23,26 @@ https://jitpack.io/#multiform-validator/java/
2323 - isCreditCardValid
2424 - identifyCreditCard
2525
26+ - FileValidator
27+ - isValidAudio
28+ - file (File) - required
29+ - audioExtensions (String[ ] ) - default: [ "mp3", "wav"]
30+ - You can exclude the extensions you don't want to validate
31+ - isValidImage
32+ - file (File) - required
33+ - imageExtensions (String[ ] ) - default: [ "ico", "jpeg", "png", "gif"]
34+ - You can exclude the extensions you don't want to validate
35+ - isValidPdf
36+ - file (File) - required
37+ - pdfExtensions (String) - default: "pdf"
38+ - isValidTxt
39+ - file (File) - required
40+ - txtExtensions (String) - default: "txt"
2641- Utils
2742 - getOnlyEmail
2843 - getOnlyEmailWithOptions (options)
2944 - multiple (boolean) - default: false
30- - cleanDomain (boolean) - default: false
45+ - cleanDomain (boolean | Arrays< String > ) - default: false
3146 - repeatEmail (boolean) - default: false
3247
3348- Validate
@@ -109,6 +124,34 @@ public class Main {
109124}
110125```
111126
127+ ### FileValidator
128+
129+ ``` java
130+ import io.github.multiform_validator.FileValidator ;
131+
132+ import java.io.File ;
133+
134+ public class Main {
135+ public static void main (String [] args ) {
136+ File file = new File (" path/to/file" );
137+ System . out. println(FileValidator . isValidAudio(file)); // true | false
138+ System . out. println(FileValidator . isValidImage(file)); // true | false
139+ System . out. println(FileValidator . isValidPdf(file)); // true | false
140+ System . out. println(FileValidator . isValidTxt(file)); // true | false
141+
142+ exampleExcludingExtensions();
143+ }
144+
145+ public static void exampleExcludingExtensions () {
146+ File file = new File (" path/to/file" );
147+ String [] audioExtensions = {" mp3" };
148+ String [] imageExtensions = {" ico" , " jpeg" , " png" };
149+ System . out. println(FileValidator . isValidAudio(file, audioExtensions)); // true | false
150+ System . out. println(FileValidator . isValidImage(file, imageExtensions)); // false | true
151+ }
152+ }
153+ ```
154+
112155### Utils
113156
114157``` java
@@ -117,12 +160,12 @@ import io.github.multiform_validator.Utils;
117160public class Main {
118161 public static void main (String [] args ) {
119162 String msg1 = " This is a message example with foo@bar.com email to test" ;
120- System . out. println(Utils . getOnlyEmail(msg1)); // foo@bar.com
163+ System . out. println(Utils . getOnlyEmail(msg1, null )); // foo@bar.com
121164
122165 String msg2 = " Example two foo1@bar.com and foo2@bar.com" ;
123166 // With options
124167 Utils . GetOnlyEmailOptionsParams options = new Utils .GetOnlyEmailOptionsParams ();
125- options. multiple = true ;
168+ options. setMultiple( true ) ;
126169 System . out. println(Utils . getOnlyEmailWithOptions(msg2, options)); // [foo1@bar.com, foo2@bar.com]
127170 }
128171}
@@ -134,6 +177,8 @@ public class Main {
134177import io.github.multiform_validator.Validate ;
135178import io.github.multiform_validator.Validate.ValidateEmailOptionsParams ;
136179
180+ import java.util.Collections ;
181+
137182public class Main {
138183 public static void main (String [] args ) {
139184 validateEmailExample();
@@ -148,27 +193,27 @@ public class Main {
148193
149194 // Email validation with options: maxLength
150195 ValidateEmailOptionsParams optionsMaxLength = new ValidateEmailOptionsParams ();
151- optionsMaxLength. maxLength = 10 ; // Setting max length to 10, which should fail for longer emails
196+ optionsMaxLength. setMaxLength( 10 ) ; // Setting max length to 10, which should fail for longer emails
152197 boolean isValidMaxLength = Validate . validateEmail(" longemail@example.com" , optionsMaxLength);
153198 System . out. println(" Is valid with maxLength: " + isValidMaxLength); // Expected: false
154199
155200 // Email validation with options: country specific
156201 ValidateEmailOptionsParams optionsCountry = new ValidateEmailOptionsParams ();
157- optionsCountry. country = " us" ; // Expecting an email from the US
202+ optionsCountry. setCountry( " us" ) ; // Expecting an email from the US
158203 boolean isNotValidCountry = Validate . validateEmail(" example@domain.com" , optionsCountry);
159204 boolean isValidCountry = Validate . validateEmail(" example@domain.com.us" , optionsCountry);
160205 System . out. println(" Is not valid with country: " + isNotValidCountry); // Expected: false
161206 System . out. println(" Is valid with country: " + isValidCountry); // Expected: true
162207
163208 // Email validation with options: validDomains
164209 ValidateEmailOptionsParams optionsValidDomains = new ValidateEmailOptionsParams ();
165- optionsValidDomains. validDomains = true ; // Only allow certain domains (implementation specific)
210+ optionsValidDomains. setValidDomains( true ) ; // Only allow certain domains (implementation specific)
166211 boolean isValidValidDomains = Validate . validateEmail(" example@gmail.com" , optionsValidDomains);
167212 System . out. println(" Is valid with validDomains: " + isValidValidDomains); // Expected: true
168213
169214 // Email validation with options: validDomainsList
170215 ValidateEmailOptionsParams optionsValidDomainsList = new ValidateEmailOptionsParams ();
171- optionsValidDomainsList. validDomainsList . add (" specificdomain.com" ); // Adding a specific domain to the list
216+ optionsValidDomainsList. setValidDomainsList( Collections . singletonList (" specificdomain.com" ) ); // Adding a specific domain to the list
172217 boolean isValidValidDomainsList = Validate . validateEmail(" example@specificdomain.com" , optionsValidDomainsList);
173218 System . out. println(" Is valid with validDomainsList: " + isValidValidDomainsList); // Expected: true
174219 }
0 commit comments