You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README-updated.md
+148-2Lines changed: 148 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -365,11 +365,157 @@ TextFormField(
365
365
see [override_form_builder_localizations_en](example/lib/override_form_builder_localizations_en.dart) for more detail.
366
366
367
367
## Migrations
368
-
369
368
### v11 to v12
370
369
- Deprecate `FormBuilderValidators` class with its static methods as validators.
371
370
- Instead, you should use `Validators` class.
372
-
TODO implement the remaining of breaking changes
371
+
- Instructions on how to update each old API validator to the new API equivalent:
372
+
-**checkNullOrEmpty**: Before specifying the equivalent to each validator, it is important to deal with the `checkNullOrEmpty` parameter. Every validator from the old API has this parameters, thus we are going to use this section to specify how to handle this situation for most of the cases and we will assume that this aspect is already handled for the following sections:
373
+
-`checkNullOrEmpty = true`: Given the old api: `FormBuilderValidators.someValidator(..., checkNullOrEmpty:true)`, the equivalent in the new API is `Validators.required(Validators.someEquivalentValidator(...))`.
374
+
-`checkNullOrEmpty = false`: Given the old api: `FormBuilderValidators.someValidator(..., checkNullOrEmpty:false)`, the equivalent in the new API is `Validators.optional(Validators.someEquivalentValidator(...))`.
375
+
- Bool validators
376
+
- For this group of validators, it is expected to receive a `String` as user input. Thus, if your
377
+
form widget does not guarantee a `String` input (it may receive an `Object`), you must wrap the
378
+
equivalent validator with the type validator for strings. Thus, instead of
379
+
`Validators.hasMin<Something>Chars(...)`, use `Validators.string(Validators.hasMin<Something>Chars(...))`
380
+
- `FormBuilderValidators.hasLowercaseChars(atLeast: n, regex: reg, errorText: 'some error')` is
381
+
equivalent to `Validators.hasMinLowercaseChars(min: n, customLowercaseCounter:(input)=>reg.allMatches(input).length, hasMinLowercaseCharsMsg:(_, __)=>'some error')`
382
+
- `FormBuilderValidators.hasNumericChars(atLeast: n, regex: reg, errorText: 'some error')` is
383
+
equivalent to `Validators.hasMinNumericChars(min: n, customNumericCounter:(input)=>reg.allMatches(input).length, hasMinNumericCharsMsg:(_, __)=>'some error')`
384
+
- `FormBuilderValidators.hasSpecialChars(atLeast: n, regex: reg, errorText: 'some error')` is
385
+
equivalent to `Validators.hasMinSpecialChars(min: n, customSpecialCounter:(input)=>reg.allMatches(input).length, hasMinSpecialCharsMsg:(_, __)=>'some error')`
386
+
- `FormBuilderValidators.hasUppercaseChars(atLeast: n, regex: reg, errorText: 'some error')` is
387
+
equivalent to `Validators.hasMinUppercaseChars(min: n, customUppercaseCounter:(input)=>reg.allMatches(input).length, hasMinUppercaseCharsMsg:(_, __)=>'some error')`
388
+
389
+
<<<<<<<<<<<<<<<CONTINUETHETODO>>>>>>>>>>>>>>>
390
+
-`FormBuilderValidators.isFalse()` - requires the field's to be false.
391
+
-`FormBuilderValidators.isTrue()` - requires the field's to be true.
392
+
393
+
### Collection validators
394
+
395
+
-`FormBuilderValidators.containsElement()` - requires the field's to be in the provided list.
396
+
-`FormBuilderValidators.equalLength()` - requires the length of the field's value to be equal to the provided minimum length.
397
+
-`FormBuilderValidators.maxLength()` - requires the length of the field's value to be less than or equal to the provided maximum size.
398
+
-`FormBuilderValidators.minLength()` - requires the length of the field's value to be greater than or equal to the provided minimum length.
399
+
-`FormBuilderValidators.range()` - requires the field's to be within a range.
400
+
-`FormBuilderValidators.unique()` - requires the field's to be unique in the provided list.
401
+
402
+
### Core validators
403
+
404
+
-`FormBuilderValidators.aggregate()` - runs the validators in parallel, collecting all errors.
405
+
-`FormBuilderValidators.compose()` - runs each validator against the value provided.
406
+
-`FormBuilderValidators.conditional()` - conditionally runs a validator against the value provided.
407
+
-`FormBuilderValidators.defaultValue()` - runs the validator using the default value when the provided value is null.
408
+
-`FormBuilderValidators.equal()` - requires the field's value to be equal to the provided object.
409
+
-`FormBuilderValidators.log()` - runs the validator and logs the value at a specific point in the validation chain.
410
+
-`FormBuilderValidators.notEqual()` - requires the field's value to be not equal to the provided object.
411
+
-`FormBuilderValidators.or()` - runs each validator against the value provided and passes when any works.
412
+
-`FormBuilderValidators.required()` - requires the field to have a non-empty value.
413
+
-`FormBuilderValidators.skipWhen()` - runs the validator and skips the validation when a certain condition is met.
414
+
-`FormBuilderValidators.transform()` - transforms the value before running the validator.
415
+
416
+
### Datetime validators
417
+
418
+
-`FormBuilderValidators.dateFuture()` - requires the field's value to be in the future.
419
+
-`FormBuilderValidators.datePast()` - requires the field's value to be a in the past.
420
+
-`FormBuilderValidators.dateRange()` - requires the field's value to be a within a date range.
421
+
-`FormBuilderValidators.dateTime()` - requires the field's value to be a valid date time.
422
+
-`FormBuilderValidators.date()` - requires the field's value to be a valid date string.
423
+
-`FormBuilderValidators.time()` - requires the field's value to be a valid time string.
424
+
-`FormBuilderValidators.timeZone()` - requires the field's value to be a valid time zone.
425
+
426
+
### File validators
427
+
428
+
-`FormBuilderValidators.fileExtension()` - requires the field's value to a valid file extension.
429
+
-`FormBuilderValidators.fileName()` - requires the field's to be a valid file name.
430
+
-`FormBuilderValidators.fileSize()` - requires the field's to be less than the max size.
431
+
-`FormBuilderValidators.mimeType()` - requires the field's value to a valid MIME type.
432
+
-`FormBuilderValidators.path()` - requires the field's to be a valid file or folder path.
433
+
434
+
### Finance validators
435
+
436
+
-`FormBuilderValidators.bic()` - requires the field's to be a valid BIC.
437
+
-`FormBuilderValidators.creditCardCVC()` - requires the field's value to be a valid credit card CVC number.
438
+
-`FormBuilderValidators.creditCardExpirationDate()` - requires the field's value to be a valid credit card expiration date and can check if not expired yet.
439
+
-`FormBuilderValidators.creditCard()` - requires the field's value to be a valid credit card number.
440
+
-`FormBuilderValidators.iban()` - requires the field's to be a valid IBAN.
441
+
442
+
### Identity validators
443
+
444
+
-`FormBuilderValidators.city()` - requires the field's value to be a valid city name.
445
+
-`FormBuilderValidators.country()` - requires the field's value to be a valid country name.
446
+
-`FormBuilderValidators.firstName()` - requires the field's value to be a valid first name.
447
+
-`FormBuilderValidators.lastName()` - requires the field's value to be a valid last name.
448
+
-`FormBuilderValidators.passportNumber()` - requires the field's value to be a valid passport number.
449
+
-`FormBuilderValidators.password()` - requires the field's to be a valid password that matched required conditions.
450
+
-`FormBuilderValidators.ssn()` - requires the field's to be a valid SSN (Social Security Number).
451
+
-`FormBuilderValidators.state()` - requires the field's value to be a valid state name.
452
+
-`FormBuilderValidators.street()` - requires the field's value to be a valid street name.
453
+
-`FormBuilderValidators.username()` - requires the field's to be a valid username that matched required conditions.
454
+
-`FormBuilderValidators.zipCode()` - requires the field's to be a valid zip code.
455
+
456
+
### Network validators
457
+
458
+
-`FormBuilderValidators.email()` - requires the field's value to be a valid email address.
459
+
-`FormBuilderValidators.ip()` - requires the field's value to be a valid IP address.
460
+
-`FormBuilderValidators.latitude()` - requires the field's to be a valid latitude.
461
+
-`FormBuilderValidators.longitude()` - requires the field's to be a valid longitude.
462
+
-`FormBuilderValidators.macAddress()` - requires the field's to be a valid MAC address.
463
+
-`FormBuilderValidators.phoneNumber()` - requires the field's value to be a valid phone number.
464
+
-`FormBuilderValidators.portNumber()` - requires the field's to be a valid port number.
465
+
-`FormBuilderValidators.url()` - requires the field's value to be a valid URL.
466
+
467
+
### Numeric validators
468
+
469
+
-`FormBuilderValidators.between()` - requires the field's to be between two numbers.
470
+
-`FormBuilderValidators.evenNumber()` - requires the field's to be an even number.
471
+
-`FormBuilderValidators.integer()` - requires the field's value to be an integer.
472
+
-`FormBuilderValidators.max()` - requires the field's value to be less than or equal to the provided number.
473
+
-`FormBuilderValidators.min()` - requires the field's value to be greater than or equal to the provided number.
474
+
-`FormBuilderValidators.negativeNumber()` - requires the field's to be a negative number.
475
+
-`FormBuilderValidators.notZeroNumber()` - requires the field's to be not a number zero.
476
+
-`FormBuilderValidators.numeric()` - requires the field's value to be a valid number.
477
+
-`FormBuilderValidators.oddNumber()` - requires the field's to be an odd number.
478
+
-`FormBuilderValidators.positiveNumber()` - requires the field's to be a positive number.
479
+
-`FormBuilderValidators.prime()` - requires the field's to be a prime number.
480
+
481
+
### String validators
482
+
483
+
-`FormBuilderValidators.alphabetical()` - requires the field's to contain only alphabetical characters.
484
+
-`FormBuilderValidators.contains()` - requires the substring to be in the field's value.
485
+
-`FormBuilderValidators.endsWith()` - requires the substring to be the end of the field's value.
486
+
-`FormBuilderValidators.lowercase()` - requires the field's value to be lowercase.
487
+
-`FormBuilderValidators.matchNot()` - requires the field's value to not match the provided regex pattern.
488
+
-`FormBuilderValidators.match()` - requires the field's value to match the provided regex pattern.
489
+
-`FormBuilderValidators.maxWordsCount()` - requires the word count of the field's value to be less than or equal to the provided maximum count.
490
+
-`FormBuilderValidators.minWordsCount()` - requires the word count of the field's value to be greater than or equal to the provided minimum count.
491
+
-`FormBuilderValidators.singleLine()` - requires the field's string to be a single line of text.
492
+
-`FormBuilderValidators.startsWith()` - requires the substring to be the start of the field's value.
493
+
-`FormBuilderValidators.uppercase()` - requires the field's value to be uppercase.
494
+
495
+
### Use-case validators
496
+
497
+
-`FormBuilderValidators.base64()` - requires the field's to be a valid base64 string.
498
+
-`FormBuilderValidators.colorCode()` - requires the field's value to be a valid color code.
499
+
-`FormBuilderValidators.duns()` - requires the field's value to be a valid DUNS.
500
+
-`FormBuilderValidators.isbn()` - requires the field's to be a valid ISBN.
501
+
-`FormBuilderValidators.json()` - requires the field's to be a valid json string.
502
+
-`FormBuilderValidators.languageCode()` - requires the field's to be a valid language code.
503
+
-`FormBuilderValidators.licensePlate()` - requires the field's to be a valid license plate.
504
+
-`FormBuilderValidators.uuid()` - requires the field's to be a valid uuid.
505
+
-`FormBuilderValidators.vin()` - requires the field's to be a valid VIN number.
506
+
507
+
### Extension method validators
508
+
509
+
Used for chaining and combining multiple validators.
510
+
511
+
-`FormBuilderValidator.and()` - Combines the current validator with another validator using logical AND.
512
+
-`FormBuilderValidator.or()` - Combines the current validator with another validator using logical OR.
513
+
-`FormBuilderValidator.when()` - Adds a condition to apply the validator only if the condition is met.
514
+
-`FormBuilderValidator.unless()` - Adds a condition to apply the validator only if the condition is not met.
515
+
-`FormBuilderValidator.transform()` - Transforms the value before applying the validator.
516
+
-`FormBuilderValidator.skipWhen()` - Skips the validator if the condition is met.
517
+
-`FormBuilderValidator.log()` - Logs the value during the validation process.
518
+
-`FormBuilderValidator.withErrorMessage()` - Overrides the error message of the current validator.
0 commit comments