Flutter Plugin for Reading and Validation of Identification Documents

Document Reader Core (Flutter)

Regula Document Reader SDK allows you to read various kinds of identification documents, passports, driving licenses, ID cards, etc. All processing is performed completely offline on your device. No any data leaving your device.

Documentation

The documentation can be found here.

Demo application

The demo application can be found here: https://github.com/regulaforensics/DocumentReader-Flutter.

Use this package as a library

Depend on it

Run this command:

With Flutter:

 $ flutter pub add flutter_document_reader_core_barcodemrzrfid

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
  flutter_document_reader_core_barcodemrzrfid: ^6.4.0

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

Import it

Now in your Dart code, you can use:

import 'package:flutter_document_reader_core_barcodemrzrfid/flutter_document_reader_core_barcodemrzrfid.dart'; 

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:flutter_document_reader_core_barcodemrzrfid/flutter_document_reader_core_barcodemrzrfid.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      platformVersion = await FlutterDocumentReaderCore.platformVersion;
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text('Running on: $_platformVersion\n'),
        ),
      ),
    );
  }
} 

Download Details:

Author: regulaforensics

Source Code: https://github.com/regulaforensics/DocumentReader-Flutter

#flutter #android #validators 

Flutter Plugin for Reading and Validation of Identification Documents
Rupert  Beatty

Rupert Beatty

1658442540

Laravel-Phone: Phone Number Functionality for Laravel

Laravel Phone

Adds phone number functionality to Laravel based on the PHP port of Google's libphonenumber API by giggsey.

Installation

Run the following command to install the latest applicable version of the package:

composer require propaganistas/laravel-phone

The Service Provider gets discovered automatically by Laravel.

In your languages directory, add an extra translation in every validation.php language file:

'phone' => 'The :attribute field contains an invalid number.',

Validation

To validate a phone number, use the phone keyword in your validation rules array or use the Phone rule class to define the rule in an expressive way. The phone validator is able to operate in three ways.

You either specify ISO 3166-1 alpha-2 compliant country codes yourself as parameters for the validator, e.g.:

'phonefield'       => 'phone:US,BE',
// 'phonefield'    => Rule::phone()->country(['US', 'BE'])

The validator will check if the number is valid in at least one of provided countries, so feel free to add as many country codes as you like.

You provide a dedicated country input field (keyed by ISO 3166-1 compliant country codes) to allow end users to supply a country on their own. Make sure the country field has the same name as the phone field but with _country appended for automatic discovery, or provide your custom country field name as a parameter to the validator:

'phonefield'            => 'phone',
// 'phonefield'         => Rule::phone()
'phonefield_country'    => 'required_with:phonefield',
'phonefield'            => 'phone:custom_country_field',
// 'phonefield'         => Rule::phone()->countryField('custom_country_field')
'custom_country_field'  => 'required_with:phonefield',

You instruct the validator to detect which country the number belongs to using the AUTO keyword (and optionally any fallback countries):

'phonefield'       => 'phone:AUTO,US',
// 'phonefield'    => Rule::phone()->detect()->country('US')

The validator will try to extract the country from the number itself and then check if the number is valid for that country. If the country could not be guessed it will be validated using the fallback countries if provided. Note that country guessing will only work when phone numbers are entered in international format (prefixed with a + sign, e.g. +32 ....). Leading double zeros will NOT be parsed correctly as this isn't an established consistency.

To specify constraints on the number type, just append the allowed types to the end of the parameters, e.g.:

'phonefield'       => 'phone:US,BE,mobile',
// 'phonefield'    => Rule::phone()->country(['US', 'BE'])->type('mobile')
// 'phonefield'    => Rule::phone()->country('US', 'BE')->mobile()

The most common types are mobile and fixed_line, but feel free to use any of the types defined here.

You can also enable more lenient validation (for example, fixed lines without area codes) by using the LENIENT parameter. This feature inherently doesn't play well with country autodetection and number type validation, so use such combo at own risk.

'phonefield'       => 'phone:LENIENT,US',
// 'phonefield'    => Rule::phone()->lenient()->country('US')

Attribute casting

Two cast classes are provided for automatic casting of Eloquent model attributes:

use Illuminate\Database\Eloquent\Model;
use Propaganistas\LaravelPhone\Casts\RawPhoneNumberCast;
use Propaganistas\LaravelPhone\Casts\E164PhoneNumberCast;

class User extends Model
{
    public $casts = [
        'phone' => RawPhoneNumberCast::class.':BE',
        'another_phone' => E164PhoneNumberCast::class.':BE',
    ];
}

Both classes automatically cast the database value to a PhoneNumber object for further use in your application.

$user->phone // PhoneNumber object or null

When setting a value, they both accept a string value or a PhoneNumber object. The RawPhoneNumberCast mutates the database value to the raw input number, while the E164PhoneNumberCast writes a formatted E.164 phone number to the database.

In case of RawPhoneNumberCast, the cast needs to be hinted about the phone country in order to properly parse the raw number into a phone object. In case of E164PhoneNumberCast and the value to be set is not already in some international format, the cast needs to be hinted about the phone country in order to properly mutate the value.

Both classes accept cast parameters in the same way:

  1. When a similar named attribute exists, but suffixed with _country (e.g. phone_country), the cast will detect and use it automatically.
  2. Provide another attribute's name as a cast parameter
  3. Provide one or several country codes as cast parameters
public $casts = [
    'phone' => RawPhoneNumberCast::class.':country_field',
    'another_phone' => E164PhoneNumberCast::class.':BE',
];

In order to not encounter any unexpected issues when using these casts, please always validate any input using the validation rules previously described.

⚠️ Attribute assignment and E164PhoneNumberCast

Due to the nature of E164PhoneNumberCast a valid country attribute is expected if the number is not passed in international format. Since casts are applied in the order of the given values, be sure to set the country attribute before setting the phone number attribute. Otherwise E164PhoneNumberCast will encounter an empty country value and throw an unexpected exception.

// Wrong
$model->fill([
    'phone' => '012 34 56 78',
    'phone_country' => 'BE',
]);

// Correct
$model->fill([
    'phone_country' => 'BE',
    'phone' => '012 34 56 78',
]);

// Wrong
$model->phone = '012 34 56 78';
$model->phone_country = 'BE';

// Correct
$model->phone_country = 'BE';
$model->phone = '012 34 56 78';

Utility PhoneNumber class

A phone number can be wrapped in the Propaganistas\LaravelPhone\PhoneNumber class to enhance it with useful utility methods. It's safe to directly reference these objects in views or when saving to the database as they will degrade gracefully to the E.164 format.

use Propaganistas\LaravelPhone\PhoneNumber;

(string) PhoneNumber::make('+3212/34.56.78');              // +3212345678
(string) PhoneNumber::make('012 34 56 78', 'BE');          // +3212345678
(string) PhoneNumber::make('012345678')->ofCountry('BE');  // +3212345678

Formatting

A PhoneNumber can be formatted in various ways:

PhoneNumber::make('012 34 56 78', 'BE')->format($format);       // See libphonenumber\PhoneNumberFormat
PhoneNumber::make('012 34 56 78', 'BE')->formatE164();          // +3212345678
PhoneNumber::make('012 34 56 78', 'BE')->formatInternational(); // +32 12 34 56 78
PhoneNumber::make('012 34 56 78', 'BE')->formatRFC3966();       // +32-12-34-56-78
PhoneNumber::make('012/34.56.78', 'BE')->formatNational();      // 012 34 56 78

// Formats so the number can be called straight from the provided country.
PhoneNumber::make('012 34 56 78', 'BE')->formatForCountry('BE'); // 012 34 56 78
PhoneNumber::make('012 34 56 78', 'BE')->formatForCountry('NL'); // 00 32 12 34 56 78
PhoneNumber::make('012 34 56 78', 'BE')->formatForCountry('US'); // 011 32 12 34 56 78

// Formats so the number can be clicked on and called straight from the provided country using a cellphone.
PhoneNumber::make('012 34 56 78', 'BE')->formatForMobileDialingInCountry('BE'); // 012345678
PhoneNumber::make('012 34 56 78', 'BE')->formatForMobileDialingInCountry('NL'); // +3212345678
PhoneNumber::make('012 34 56 78', 'BE')->formatForMobileDialingInCountry('US'); // +3212345678

Number information

Get some information about the phone number:

PhoneNumber::make('012 34 56 78', 'BE')->getType();              // 'fixed_line'
PhoneNumber::make('012 34 56 78', 'BE')->isOfType('fixed_line'); // true
PhoneNumber::make('012 34 56 78', 'BE')->getCountry();           // 'BE'
PhoneNumber::make('012 34 56 78', 'BE')->isOfCountry('BE');      // true
PhoneNumber::make('+32 12 34 56 78')->isOfCountry('BE');         // true

Helper function

The package exposes the phone() helper function that returns a Propaganistas\LaravelPhone\PhoneNumber instance or the formatted string if $format was provided:

phone($number, $country = [], $format = null)

Database considerations

Disclaimer: Phone number handling is quite different in each application. The topics mentioned below are therefore meant as a set of thought starters; support will not be provided.

Storing phone numbers in a database has always been a speculative topic and there's simply no silver bullet. It all depends on your application's requirements. Here are some things to take into account, along with an implementation suggestion. Your ideal database setup will probably be a combination of some of the pointers detailed below.

Uniqueness

The E.164 format globally and uniquely identifies a phone number across the world. It also inherently implies a specific country and can be supplied as-is to the phone() helper.

You'll need:

  • One column to store the phone number
  • To format the phone number to E.164 before persisting it

Example:

  • User input = 012/45.65.78
  • Database column
    • phone (varchar) = +3212456578

Presenting the phone number the way it was inputted

If you store formatted phone numbers the raw user input will unretrievably get lost. It may be beneficial to present your users with their very own inputted phone number, for example in terms of improved user experience.

You'll need:

  • Two columns to store the raw input and the correlated country

Example:

  • User input = 012/34.56.78
  • Database columns
    • phone (varchar) = 012/34.56.78
    • phone_country (varchar) = BE

Supporting searches

Searching through phone numbers can quickly become ridiculously complex and will always require deep understanding of the context and extent of your application. Here's a possible approach covering quite a lot of "natural" use cases.

You'll need:

  • Three additional columns to store searchable variants of the phone number:
    • Normalized input (raw input with all non-alpha characters stripped)
    • National formatted phone number (with all non-alpha characters stripped)
    • E.164 formatted phone number
  • Probably a saving() observer (or equivalent) to prefill the variants before persistence
  • An extensive search query utilizing the searchable variants

Example:

  • User input = 12/34.56.78
  • Observer method:
public function saving(User $user)
{
    if ($user->isDirty('phone') && $user->phone) {
        $user->phone_normalized = preg_replace('[^0-9]', '', $user->phone);
        $user->phone_national = preg_replace('[^0-9]', '', phone($user->phone, $user->phone_country)->formatNational());
        $user->phone_e164 = phone($user->phone, $user->phone_country)->formatE164();
    }
}
  • Database columns
    • phone_normalized (varchar) = 12345678
    • phone_national (varchar) = 012345678
    • phone_e164 (varchar) = +3212345678
  • Search query:
// $search holds the search term
User::where(function($query) use ($search) {
  $query->where('phone_normalized', 'LIKE', preg_replace('[^0-9]', '', $search) . '%')
        ->orWhere('phone_national', 'LIKE', preg_replace('[^0-9]', '', $search) . '%')
        ->orWhere('phone_e164', 'LIKE', preg_replace('[^+0-9]', '', $search) . '%')
});

Demo

Check out the behavior of this package in the demo.

Author: Propaganistas
Source Code: https://github.com/Propaganistas/Laravel-Phone 
License: MIT license

#laravel #phone #validators 

Laravel-Phone: Phone Number Functionality for Laravel

Flutter Password Validator Package Helps You to Validate Sign-in

Flutter Password Validator


 

Flutter Password Validator package helps you to validate sign-in user-entered passwords with your rules.

How to use

1- Depend on it

Add it to your package's pubspec.yaml file:

dependencies:
  flutter_pw_validator: ^1.4.2

2- Install it

Install packages from the command line:

flutter pub get

3- Usage

First You have to import the file:

import 'package:flutter_pw_validator/flutter_pw_validator.dart';

And then just put it right under your password TextField and pass the controller to that:

new TextField(
    controller: _passwordController
),
new FlutterPwValidator(
    controller: _passwordController,
    minLength: 6,
    uppercaseCharCount: 2,
    numericCharCount: 3,
    specialCharCount: 1,
    width: 400,
    height: 150,
    onSuccess: yourCallbackFunction,
    onFail: yourCallbackFunction
)

Properties

PropertyDescriptionDefault ValueRequired
controllerTakes your password TextField controllernullYes
minLengthTakes total minimum length of passwordnullYes
uppercaseCharCountTakes minimum uppercase character count that has to include in the password0No
numericCharCountTakes minimum numeric character count that has to include in the password0No
specialCharCountTakes minimum special character count that has to include in the password0No
widthTakes the widget widthnullYes
heightTakes the widget heightnullYes
onSuccessA void callback function that runs when the password is matched with the condition(s)nullYes
onFailA void callback that gets called everytime the password doesn't match with the condition(s)nullNo
defaultColorTakes default state color of the widgetColor(0xFFd3d3d3)No
successColorTakes success state color of the widgetColor(0xFF2ee292)No
failureColorTakes failure state color of the widgetColor(0xFFf9433e)No
stringsA class implementing the default FlutterPwValidatorStringsEnglish FlutterPwValidatorStringsNo


 

i18n

If you want to translate this plugin simply implements the FlutterPwValidatorStrings class and pass it to the widget.

class FrenchStrings implements FlutterPwValidatorStrings {
  @override
  final String atLeast = 'Au moins - caractères';
  @override
  final String uppercaseLetters = '- Lettres majuscules';
  @override
  final String numericCharacters = '- Chiffres';
  @override
  final String specialCharacters = '- Caractères spéciaux';
}

FlutterPwValidator(
    // ...
    // your config above
    strings: FrenchStrings()
)

Example Project

You can use this example project to see how it works.

Use this package as a library

Depend on it

Run this command:

With Flutter:

 $ flutter pub add flutter_pw_validator

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
  flutter_pw_validator: ^1.4.2

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

Import it

Now in your Dart code, you can use:

import 'package:flutter_pw_validator/flutter_pw_validator.dart'; 

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_pw_validator/flutter_pw_validator.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        debugShowCheckedModeBanner: false,
        title: 'Flutter Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
          visualDensity: VisualDensity.adaptivePlatformDensity,
        ),
        home: new Scaffold(
            appBar: new AppBar(
              title: new Text("Flutter Pw Validator"),
            ),
            body: new AppHome()));
  }
}

class AppHome extends StatelessWidget {
  final TextEditingController controller = new TextEditingController();

  @override
  Widget build(BuildContext context) {
    return new Stack(children: [
      Padding(
        padding: const EdgeInsets.symmetric(vertical: 15.0, horizontal: 12.5),
        child: Column(
          children: [
            new Flexible(flex: 5, child: new FlutterLogo(size: 200)),
            Flexible(
              flex: 7,
              child: new Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Padding(
                    padding: const EdgeInsets.symmetric(horizontal: 2.0),
                    child: new TextField(
                        controller: controller,
                        decoration: new InputDecoration(
                            hintText: "Password",
                            border: new OutlineInputBorder(
                                borderSide: BorderSide()))),
                  ),
                  new SizedBox(
                    height: 5,
                  ),
                  new FlutterPwValidator(
                    controller: controller,
                    minLength: 8,
                    uppercaseCharCount: 2,
                    numericCharCount: 3,
                    specialCharCount: 1,
                    normalCharCount: 3,
                    width: 400,
                    height: 150,
                    onSuccess: () {
                      print("MATCHED");
                      ScaffoldMessenger.of(context).showSnackBar(new SnackBar(
                          content: new Text("Password is matched")));
                    },
                    onFail: () {
                      print("NOT MATCHED");
                    },
                  ),
                ],
              ),
            )
          ],
        ),
      ),
    ]);
  }
} 

Download Details:

Author: ArefMozafari

Source Code: https://github.com/ArefMozafari/flutter_pw_validator

#flutter #validators 

Flutter Password Validator Package Helps You to Validate Sign-in

Easily Expose Your CakePHP 3 Application Validation Rules

cakephp-validation-exposer

Easily expose your CakePHP 3.x application validation rules.

Why use it?

Exposing your application's validation rules can be very useful for e.g. completely separated frontend applications. Imagine a React frontend for your API being able to realtime configure (very fast) local validation rules exactly matching your CakePHP API backend's validation rules. Some benefits:

  • no more mismatches between local and backend validations
  • backend validation changes instantly applied in frontend application
  • no more fire-and-hope POSTing of data
  • less local 412 validation errors

Requirements

  • CakePHP 3.0+

Installation

Install the plugin using composer:

composer require alt3/cakephp-validation-exposer:"^1.0"

To enable the plugin either run the following command:

bin/cake plugin load Alt3/ValidationExposer

or manually add the following line to your config/bootstrap.php file:

Plugin::load('Alt3/ValidationExposer');

Usage

  1. Create a ValidationExposer object anywhere in your application
  2. Call the rules() method
  3. Present the returned array with validation information any way you see fit

API example

<?php
use Alt3\ValidationExposer\Lib\ValidationExposer;

class SystemController extends AppController
{

    public function validationInfo()
    {
        $validationExposer = new ValidationExposer([
            'excludedTables' => [
                'table_to_skip' // this table will not be processed
            ],
            'hiddenRuleParts' =>
                'message' // do not show this part inside the `rules` array
            ]
        ]);

        $this->set([
            'success' => true,
            'data' => $validationExposer->rules(),
            '_serialize' => ['success', 'data']
        ]);
    }
}

Configuration

Any table found in the excludedTables configuration array will not be searched for validation information.

Please note that the phinxlog table is excluded by default.

Add one or more of the following fields to the hiddenRuleParts configuration array and they will not appear in the result set:

  • name: holds the rule name
  • rule: holds the internal rule name (numeric, unique, etc)
  • message: holds the validation message
  • parts: holds arguments passed to the validation rule

Methods

rules()

Use the rules() method to produce a hash containing all validation information found in your application structured similarly to shown below:

[users] => Array
    (
        [id] => Array
            (
                [requiredFor] =>
                [allowedEmptyFor] => create
                [rules] => Array
                    (
                        [0] => Array
                            (
                                [name] => NUMERIC
                                [rule] => numeric
                                [message] =>
                            )

                    )

            )

        [email] => Array
            (
                [requiredFor] => create
                [allowedEmptyFor] =>
                [rules] => Array
                    (
                        [0] => Array
                            (
                                [name] => FORMAT
                                [rule] => email
                                [message] => Invalid email address format.
                            )

                        [1] => Array
                            (
                                [name] => UNIQUE
                                [rule] => validateUnique
                                [message] => This email address already exists
                            )

                    )

            )

        [password] => Array
            (
                [requiredFor] => create
                [allowedEmptyFor] =>
                [rules] => Array
                    (
                        [0] => Array
                            (
                                [name] => MIN_LENGTH
                                [rule] => minLength
                                [message] => Your password must be at least {minLength} characters.
                                [pass] => Array
                                    (
                                        [0] => 8
                                    )

                            )

                        [1] => Array
                            (
                                [name] => MAX_LENGTH
                                [rule] => maxLength
                                [message] => Your password cannot exceed {maxLength} characters
                                [pass] => Array
                                    (
                                        [0] => 255
                                    )

                            )
                    )
            )
        )

tables()

Use the tables() method to produce a flat array with all tables included in validation aggregation.

(
    [0] => cocktails
    [1] => liquors
    [2] => users
)

excludedTables()

Use the excludedTables() method to produce a flat array with tables not included in validation aggregation.

(
    [0] => phinxlog
    [1] => staging
)

Contribute

Before submitting a PR make sure:

Author: Alt3
Source Code: https://github.com/alt3/cakephp-validation-exposer 
License: MIT license

#php #cakephp #validators 

Easily Expose Your CakePHP 3 Application Validation Rules

Form Validation in Flutter

flutter_login_validations

A new Flutter project.

Getting Started

This project is a starting point for a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and/or iOS.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

"# FlutterLoginValidations"

Use this package as a library

Depend on it

Run this command:

With Flutter:

 $ flutter pub add flutter_login_validations

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
  flutter_login_validations: ^0.0.1

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

Import it

Now in your Dart code, you can use:

import 'package:flutter_login_validations/flutter_login_validations.dart'; 

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_login_validations/flutter_login_validations.dart';
import 'package:fluttertoast/fluttertoast.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  static const String _title = 'Sample App';

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: _title,
      home: Scaffold(
        appBar: AppBar(title: const Text(_title)),
        body: const MyStatefulWidget(),
      ),
    );
  }
}

class MyStatefulWidget extends StatefulWidget {
  const MyStatefulWidget({Key? key}) : super(key: key);

  @override
  State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
}

class _MyStatefulWidgetState extends State<MyStatefulWidget> {
  TextEditingController nameController = TextEditingController();
  TextEditingController passwordController = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return Padding(
        padding: const EdgeInsets.all(10),
        child: ListView(
          children: <Widget>[
            Container(
                alignment: Alignment.center,
                padding: const EdgeInsets.all(10),
                child: const Text(
                  'Login',
                  style: TextStyle(
                      color: Colors.blue,
                      fontWeight: FontWeight.w500,
                      fontSize: 30),
                )),
            Container(
              padding: const EdgeInsets.all(10),
              child: TextField(
                controller: nameController,
                decoration: const InputDecoration(
                  border: OutlineInputBorder(),
                  labelText: 'User Name',
                ),
              ),
            ),
            Container(
              padding: const EdgeInsets.fromLTRB(10, 10, 10, 0),
              child: TextField(
                obscureText: true,
                controller: passwordController,
                decoration: const InputDecoration(
                  border: OutlineInputBorder(),
                  labelText: 'Password',
                ),
              ),
            ),
            Container(
                height: 50,
                margin:const EdgeInsets.fromLTRB(0, 20, 0, 0),
                padding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
                child: ElevatedButton(
                  child: const Text('Login'),
                  onPressed: () {
                    if(isValid(nameController.text,passwordController.text)){
                      Fluttertoast.showToast(
                          msg: "Successful login"
                      );
                    }
                  },
                )
            ),
          ],
        ));
  }

  bool isValid(String email, String password) {
    bool valid = false;
    if(FlutterLoginValidations.checkFieldIsEmptyOrNot(nameController.text)){
      if(FlutterLoginValidations.emailValidation(nameController.text)){
        if(FlutterLoginValidations.checkFieldIsEmptyOrNot(passwordController.text)){
          if(FlutterLoginValidations.passwordValidationWithoutSpecialCharacters(password, 7, 10)){
            valid = true;
          }
          else{
            Fluttertoast.showToast(
                msg: "Password length should be with in range"
            );
          }
        }
        else{
          Fluttertoast.showToast(
              msg: "Please enter password"
          );
        }
      }
      else{
        Fluttertoast.showToast(
            msg: "Please enter valid mail id"
        );
      }
    }
    else{
      Fluttertoast.showToast(
          msg: "Please enter mail id"
      );
    }
   return valid;
  }
} 

Download Details:

Author: 

Source Code: https://pub.dev/packages/flutter_login_validations

#flutter #validators #login 

Form Validation in Flutter

Formsy-react: A form input builder and validator for React JS

formsy-react    

A form input builder and validator for React.

Quick StartAPI1.x API

Background

christianalfoni wrote an article on forms and validation with React, Nailing that validation with React JS, the result of that was this library.

The main concept is that forms, inputs, and validation are done very differently across developers and projects. This React component aims to be that “sweet spot” between flexibility and reusability.

This project was originally located at christianalfoni/formsy-react if you're looking for old issues.

What You Can Do

  1. Build any kind of form element components. Not just traditional inputs, but anything you want, and get that validation for free
  2. Add validation rules and use them with simple syntax
  3. Use handlers for different states of your form. (onSubmit, onValid, etc.)
  4. Pass external errors to the form to invalidate elements (E.g. a response from a server)
  5. Dynamically add form elements to your form and they will register/unregister to the form

Install

yarn add formsy-react react react-dom and use with webpack, browserify, etc.

Formsy component packages

1.x to 2.x Upgrade Guide

The 2.0 release fixed a number of legacy decisions in the Formsy API, mostly a reliance on function props over value props passed down to wrapped components. However, the API changes are minor and listed below.

  • getErrorMessage() => errorMessage
  • getErrorMessages() => errorMessages
  • getValue() => value
  • hasValue() => hasValue
  • isFormDisabled(): => isFormDisabled
  • isFormSubmitted() => isFormSubmitted
  • isPristine() => isPristine
  • isRequired() => isRequired
  • isValid(): => isValid
  • showError() => showError
  • showRequired() => showRequired

Quick Start

1. Build a Formsy element

// MyInput.js
import { withFormsy } from 'formsy-react';
import React from 'react';

class MyInput extends React.Component {
  constructor(props) {
    super(props);
    this.changeValue = this.changeValue.bind(this);
  }

  changeValue(event) {
    // setValue() will set the value of the component, which in
    // turn will validate it and the rest of the form
    // Important: Don't skip this step. This pattern is required
    // for Formsy to work.
    this.props.setValue(event.currentTarget.value);
  }

  render() {
    // An error message is passed only if the component is invalid
    const errorMessage = this.props.errorMessage;

    return (
      <div>
        <input onChange={this.changeValue} type="text" value={this.props.value || ''} />
        <span>{errorMessage}</span>
      </div>
    );
  }
}

export default withFormsy(MyInput);

withFormsy is a Higher-Order Component that exposes additional props to MyInput. See the API documentation to view a complete list of the props.

2. Use your Formsy element

import Formsy from 'formsy-react';
import React from 'react';
import MyInput from './MyInput';

export default class App extends React.Component {
  constructor(props) {
    super(props);
    this.disableButton = this.disableButton.bind(this);
    this.enableButton = this.enableButton.bind(this);
    this.state = { canSubmit: false };
  }

  disableButton() {
    this.setState({ canSubmit: false });
  }

  enableButton() {
    this.setState({ canSubmit: true });
  }

  submit(model) {
    fetch('http://example.com/', {
      method: 'post',
      body: JSON.stringify(model),
    });
  }

  render() {
    return (
      <Formsy onValidSubmit={this.submit} onValid={this.enableButton} onInvalid={this.disableButton}>
        <MyInput name="email" validations="isEmail" validationError="This is not a valid email" required />
        <button type="submit" disabled={!this.state.canSubmit}>
          Submit
        </button>
      </Formsy>
    );
  }
}

This code results in a form with a submit button that will run the submit method when the form is submitted with a valid email. The submit button is disabled as long as the input is empty (required) and the value is not an email (isEmail). On validation error it will show the message: "This is not a valid email".

3. More

See the API for more information.

Contribute

  • Fork repo
  • yarn
  • yarn lint runs lint checks
  • yarn test runs the tests
  • npm run deploy build and release formsy

Changelog

Check out our Changelog and releases

Author: Formsy
Source Code: https://github.com/formsy/formsy-react/ 
License: MIT license

#react #typescript #validators #form 

Formsy-react: A form input builder and validator for React JS

How to Get Start with C# Null Checks and Argument Validation

Stop writing complex logic to validate your method arguments and use Guard, part of the .NET Community Toolkit. Guard is faster, less verbose, more expressive, and less error prone than manually writing checks and throwing exceptions. Today, I break down everything you need to know and how to get started.

Chapters: 
00:00 - Intro
00:32 - .NET Community Toolkit Overview
01:20 - Why validate arguments with Guard
02:40 - Setting up diagnostics library
05:23 - Guard overview with demo
11:55 - Wrap-up and more community toolkit

Links:
* Source code sample - https://github.com/jamesmontemagno/mvvmsourcegenerators
* Community Toolkit GitHub - https://github.com/communitytoolkit/dotnet
* Documentation - https://docs.microsoft.com/windows/communitytoolkit/developer-tools/guard
* Me and Sergio talking toolkit - https://www.youtube.com/watch?v=oKMZiDA9ogM

#csharp  #dotnet  #validators  #guard

How to Get Start with C# Null Checks and Argument Validation

A Flutter Package for Validation

Fancy Containers

flutter textfield validation lets you validate different textform fields in your Flutter app.

Installation

  1. Add the latest version of package to your pubspec.yaml (and rundart pub get):
dependencies:
  flutter_textfield_validation: ^0.0.1
  1. Import the package and use it in your Flutter App.
import 'package:flutter_textfield_validation/flutter_textfield_validation.dart';

Example

There are a number of properties that you can modify:

  1. Email Validation validateEmail() 2.Password Validation validatePassword() 3.Name Validation validateName() 4.Phone Validation validatePhone() 5.Otp Validation validateOtp() 6.Dob Validation validateDob() 7.Country code Validation validateCountryCode1() 8.State code Validation validateState() 9.City code Validation validateCity() 10.Pin code Validation validatePincode() 11.Post code Validation validatePostCode() 12.Address Validation validateAddress()

TextFormField(
                    controller: _emailController,
                    autovalidateMode: AutovalidateMode.onUserInteraction,
                    validator: (input) => input!.validateEmail()
                        ? null
                        : "Please enter valid email!!",
                    decoration: InputDecoration(
                        enabledBorder: const OutlineInputBorder(
                          borderRadius: BorderRadius.all(Radius.circular(12.0)),
                          borderSide:
                              BorderSide(color: Colors.transparent, width: 2),
                        ),
                        focusedBorder: const OutlineInputBorder(
                          borderRadius: BorderRadius.all(Radius.circular(10.0)),
                          borderSide: BorderSide(color: Colors.transparent),
                        ),
                        border: InputBorder.none,
                        filled: true,
                       // prefixIcon: const Icon(Icons.mail),
                        hintStyle: TextStyle(color: Colors.grey[800]),
                        hintText: "Enter your Email Address",
                        fillColor: Colors.grey[200]),
                  ),

Use this package as a library

Depend on it

Run this command:

With Flutter:

 $ flutter pub add flutter_textfield_validation

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
  flutter_textfield_validation: ^0.0.2

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

Import it

Now in your Dart code, you can use:

import 'package:flutter_textfield_validation/flutter_textfield_validation.dart'; 

Download Details:

Author: riyazatdurrani

Source Code: https://github.com/riyazatdurrani/fluttertextfieldvalidation

#flutter #validators 

A Flutter Package for Validation
Best of Crypto

Best of Crypto

1647313080

Cosmos Hub (Gaia): An Exploding Number Of interconnected Blockchains

Cosmos Hub (Gaia)

The Cosmos Hub is the first of an exploding number of interconnected blockchains that comprise the Cosmos Network. 

🤔 — Why should you be interested in the Cosmos Hub

The Cosmos Hub is built using the Cosmos SDK and compiled to a binary called gaiad (Gaia Daemon). The Cosmos Hub and other fully sovereign Cosmos SDK blockchains interact with one another using a protocol called IBC that enables Inter-Blockchain Communication. In order to understand what the Cosmos Hub is you can read this introductory explanation.

⚡ — Documentation & Introduction

You can find an introduction to the Cosmos Hub and how to use the gaiad binary as a delegator, validator or node operator as well as how governance on the Cosmos Hub works in the documentation

👤 — Node Operators

If you're interested in running a node on the current Cosmos Hub, check out the docs to Join the Cosmos Hub Mainnet.

🗣️ — Validators

If you're running a validator node on the Cosmos Hub, reach out to a Janitor on the Cosmos Developers Discord to join the #validators-verified channel.

👥 — Testnet

To participate in or utilize the current Cosmos Hub testnet that upgrades cosmoshub-4 from gaia v5.0.x to gaia v6.0.x, take a look at the vega-testnet repository. This testnet is for the Vega Upgrade expected in Q4 2021. For future upgrades of the Cosmos Hub take a look at the roadmap.

🌐 — Roadmap

For an overview of upcoming changes to the Cosmos Hub take a look at the Roadmap.

🗄️ — Archives & Genesis

With each version of the Cosmos Hub, the chain is restarted from a new Genesis state. Mainnet is currently running as cosmoshub-4. Archives of the state of cosmoshub-1, cosmoshub-2, and cosmoshub-3 are available here.

If you are looking for historical genesis files and other data cosmos/mainnet is an excellent resource. Snapshots are also available at cosmos.quicksync.io.

🤝 — How to contribute

Check out contributing.md for our guidelines & policies for how we develop the Cosmos Hub. Thank you to all those who have contributed!

Download Details:
Author: cosmos
Source Code: https://github.com/cosmos/gaia
License: Apache-2.0 License

#blockchain  #cosmos  #cryptocurrencies #go  #golang 

Cosmos Hub (Gaia): An Exploding Number Of interconnected Blockchains