Exclude directories & subdirectories from validation in Eclipse

I usually exclude validation in this way, I believe it will be recursive. Right-click on your project and select Properties. Choose Validation from the left-nav menu. If it is not already selected choose “Enable project specific settings”. Find the validator that is relevant for what you want to exclude and click the “…” in the … Read more

Regex for password PHP [duplicate]

^\S*(?=\S{8,})(?=\S*[a-z])(?=\S*[A-Z])(?=\S*[\d])\S*$ From the fine folks over at Zorched. ^: anchored to beginning of string \S*: any set of characters (?=\S{8,}): of at least length 8 (?=\S*[a-z]): containing at least one lowercase letter (?=\S*[A-Z]): and at least one uppercase letter (?=\S*[\d]): and at least one number $: anchored to the end of the string To include … Read more

Checking if a string contains an integer

if((string)(int)$var == $var) { echo ‘var is an integer or a string representation of an integer’; } Example results: var_dump( test(1) ); // TRUE var_dump( test(‘1’) ); // TRUE var_dump( test(‘1.0’) ); // TRUE var_dump( test(‘1.1’) ); // false var_dump( test(‘0xFF’) ); // false var_dump( test(‘0123’) ); // TRUE var_dump( test(‘01090’) ); // TRUE var_dump( … Read more

How to add form validation pattern in Angular 2?

Now, you don’t need to use FormBuilder and all this complicated valiation angular stuff. I put more details from this (Angular 2.0.8 – 3march2016): https://github.com/angular/angular/commit/38cb526 Example from repo : <input [ngControl]=”fullName” pattern=”[a-zA-Z ]*”> I test it and it works 🙂 – here is my code: <form (ngSubmit)=”onSubmit(room)” #roomForm=’ngForm’ > … <input id=’room-capacity’ type=”text” class=”form-control” [(ngModel)]=’room.capacity’ … Read more

Laravel validation: exists with additional column condition – custom validation rule

From Laravel 5.3+ you can add a custom where clause to the exists and unique rules. Here is my scenario: I have an email verification table and I want to ensure that a passed machine code and activation code exist on the same row. Be sure to use Illuminate\Validation\Rule; $activationCode = $request->activation_code; $rules = [ … Read more

Check if laravel model got saved or query got executed

Check if model got saved save() will return a boolean, saved or not saved. So you can either do: $saved = $myModel->save(); if(!$saved){ App::abort(500, ‘Error’); } Or directly save in the if: if(!$myModel->save()){ App::abort(500, ‘Error’); } Note that it doesn’t make sense to call save() two times in a row like in your example. And … Read more

Using DataAnnotations to compare two model properties

Make sure that your project references system.web.mvc v3.xxxxx. Then your code should be something like this: using System.Web.Mvc; . . . . [Required(ErrorMessage = “This field is required.”)] public string NewPassword { get; set; } [Required(ErrorMessage = “This field is required.”)] [Compare(nameof(NewPassword), ErrorMessage = “Passwords don’t match.”)] public string RepeatPassword { get; set; }