This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input type="text"[(ngModel)]="FullName" name="FullName" [NotNull]="Enter note text" [NotNullCondition]="CustomerIsAbove18" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Directive, Input, TemplateRef, NgModule, EventEmitter, Output } from '@angular/core'; | |
import { NG_VALIDATORS, Validator, AbstractControl, ValidatorFn } from '@angular/forms'; | |
//Description: This validator acts almost the same way as required validator, the difference is this validator validates the ngModel | |
//and is helpful for custom controls like ng-select where the required validator fails. | |
@Directive({ | |
selector: '[NotNull]', | |
providers: [{ provide: NG_VALIDATORS, useExisting: NotNullValidatorDirective, multi: true }] | |
}) | |
export class NotNullValidatorDirective implements Validator { | |
constructor() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public override IEnumerable<IAutomappingStep> GetMappingSteps(AutoMapper mapper, FluentNHibernate.Conventions.IConventionFinder conventionFinder) | |
{ | |
//SamerA: Replace the original HasManyToManyStep with the Customized HasManyToManyStep to allow Unidirectional ManyToMany | |
//Mapping when the other side has no reference for the current side. | |
//NOTE: an alternative to the below code is to redefine all steps with the CustomHasManyToManyStep here, the only preference is use | |
//the already created steps instead of creating new ones along with the old ones. | |
//Get all defined steps | |
var steps = base.GetMappingSteps(mapper, conventionFinder).ToList(); | |
var index = steps.FindIndex(x => x.GetType() == typeof(HasManyToManyStep)); | |
steps.RemoveAt(index); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomHasManyToManyStep : IAutomappingStep | |
{ | |
private readonly IAutomappingConfiguration cfg; | |
public CustomHasManyToManyStep(IAutomappingConfiguration cfg) | |
{ | |
this.cfg = cfg; | |
} | |
public bool ShouldMap(Member member) | |
{ | |
var type = member.PropertyType; |