“Angular erzeugen Validator” Code-Antworten

Angular Implementierung des Validators

<>Copyimport {AbstractControl, ValidatorFn} from '@angular/forms';

export function blue(): ValidatorFn {  
    return (control: AbstractControl): { [key: string]: any } | null =>  
        control.value?.toLowerCase() === 'blue' 
            ? null : {wrongColor: control.value};
}
ilirlazaj07

Angular erzeugen Validator

create a '<name>.validator.ts' File

// standard-structure
export function ConfirmedValidator(par1: string, par2: string){
    return null;
}
JBTheOneAndOnly

Validator Angular

$rules = array(
    'name'      => 'required|string|max:255',
    'email'     => 'required|string|email|max:255|unique:users',
    'role'      => 'required|string',
    'password'  => 'required|string|min:6|confirmed',
  );

  $validator = validator::make(Input::all(), $rules);

  if ($validator->fails()) {
    // return dd();
    return Redirect::to('/admin/usuarios/' . $id . '/edit')
    ->withErrors($validator);
  } else {
    // store
    $user = User::find($id);
    $user->name       = Input::get('name');
    $user->email      = Input::get('email');
    $user->role       = Input::get('role');
    $user->password   = Input::get('password');
    $user->save();

    // redirect
    Session::flash('message', 'Sucesso!');
    return Redirect::to('/admin/usuarios');
  }
Elegant Echidna

Ähnliche Antworten wie “Angular erzeugen Validator”

Fragen ähnlich wie “Angular erzeugen Validator”

Weitere verwandte Antworten zu “Angular erzeugen Validator” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen