Zum Hauptinhalt springen
LIVE
CVSS 6.9CVE-2026-137684 | A security flaw has been discovered in eosphoros-ai DB-GPT up to 0.8.3. This affects the function editor_sql_run of the file packages/dbgpt-app/src/dbgpt_app/openapi/api_v1/editor/api_editor_v1.py of the component Editor SQL Run API. Performing a manipulation of the argument db_name results in authorization bypass. It is possible to initiate the attack remotely. The exploit has been released to the public and may be used for attacks. The pull request to fixCVSS 8.7CVE-2026-137992 | libexpat through 2.11.0 contains a denial of service vulnerability in defineAttribute() of lib/xmlparse.c that fails to detect duplicate non-ID #IMPLIED or #REQUIRED attribute declarations. Attackers can supply a crafted XML document with repeated ATTLIST declarations in an internal DTD subset to cause quadratic CPU consumption in storeAtts() during parsing.CVSS 8.5CVE-2026-137994 | Leo through 6.8.10 contains an insecure deserialization vulnerability that allows attackers to execute code by embedding pickled data in unknown XML attributes of .leo outlines. Attackers can place a pickle __reduce__ gadget in a or element attribute that resolveUa passes to pickle.loads, executing code with user privileges when the outline is opened.CVSS 7.0CVE-2026-137995 | FOG Project before 1.6.0.119 contains an information disclosure vulnerability that allows unauthenticated attackers to obtain host tokens from status/hostgetkey.php by supplying a host MAC address. Attackers can present the token to service/hostinfo.php to retrieve decrypted Active Directory join credentials and Windows product keys during deployment windows.CVSS 6.8CVE-2026-137996 | Zettlr before 4.11.0 fails to validate URI schemes in Markdown link targets, allowing attackers to launch arbitrary registered protocol handlers via Electron shell.openExternal without confirmation. Attackers can craft documents whose Ctrl/Cmd-clicked links use smb:// to leak NTLM credential hashes on Windows or invoke custom protocol handlers with attacker-controlled parameters.CVSS 8.5CVE-2026-137997 | HCIPy through 0.7.1 contains an insecure deserialization vulnerability that allows attackers to execute code by supplying crafted .pkl files to read_field, read_grid or read_mode_basis. Because hcipy/util/io.py selects pickle by file extension and calls pickle.load, a __reduce__ gadget in a pupil, apodizer, PSF or mode-basis file runs code with the user's privileges.CVSS 8.5CVE-2026-137998 | Detoxify 0.5.3 through 0.5.4 contains an insecure deserialization vulnerability in load_checkpoint that allows attackers to execute code by supplying a crafted checkpoint file. Attackers can embed a pickle __reduce__ gadget in a .ckpt file loaded via torch.load with weights_only=False to run code with the user's privileges.CVSS 8.5CVE-2026-137999 | JSONSchema2PoPo2 through 3.0.3 contains a code injection vulnerability that allows attackers to inject Python code by supplying JSON Schema default or format values that are written unescaped. Attackers can place a single quote in a string property default to break out of the literal in the generated __init__ signature, executing injected code when the generated module is imported.
Alle im Drawer
Intelligence View
⚡ tsecurity.de Intelligence

RxJS in Angular — Chapter 8 | RxJS + Angular Reactive Forms — Live Validation ও Dynamic Forms

"RxJS + Angular Reactive Forms — Live Validation & Dynamic Forms" 👋 Welcome to Chapter 8! Forms are EVERYWHERE in web apps — login, registration, checkout, sear…

Beitrag
0
Seite
0
↗ Quelle (dev.to)
Quelle & Fakten · 8 Min. Lesezeit
Quelle: dev.to
Rubrik: Programación segura




"RxJS + Angular Reactive Forms — Live Validation & Dynamic Forms"









👋 Welcome to Chapter 8!



Forms are EVERYWHERE in web apps — login, registration, checkout, search, settings.



Angular's Reactive Forms are powered by RxJS under the hood. Every FormControl has streams you can subscribe to — valueChanges, statusChanges. This unlocks incredibly powerful form behavior that would be painfully difficult to build any other way.



Today we build real, production-quality forms with RxJS superpowers!









🎛️ The Reactive Forms Quick Setup



First, let's make sure we have the right setup:






app.module.ts






import { ReactiveFormsModule } from '@angular/forms';

@NgModule({
imports: [ReactiveFormsModule]
})
export class AppModule {}












💡 The Key Streams on Every FormControl



Every FormControl, FormGroup, and FormArray has two key Observable streams:



valueChanges — emits every time the value changes

statusChanges — emits every time the validation status changes ('VALID', 'INVALID', 'PENDING', 'DISABLED')




const emailControl = new FormControl('');

// Watch the value
emailControl.valueChanges.subscribe(value => {
console.log('Email is now:', value);
});

// Watch the validation status
emailControl.statusChanges.subscribe(status => {
console.log('Status:', status); // 'VALID', 'INVALID', 'PENDING', 'DISABLED'
});












🔍 Real Example 1 — Live Username Availability Check



This is extremely common: as the user types a username, check if it's available.




// register.component.ts
import { Component, OnInit, OnDestroy } from '@angular/core';
import { FormBuilder, FormGroup, Validators, AbstractControl } from '@angular/forms';
import { Subject } from 'rxjs';
import { debounceTime, distinctUntilChanged, switchMap, takeUntil } from 'rxjs/operators';

@Component({
selector: 'app-register',
template: `
<form [formGroup]="registerForm" (ngSubmit)="onSubmit()">

<div class="field">
<label>Username</label>
<input formControlName="username" placeholder="Choose a username" />

<!-- Checking availability -->
<span *ngIf="isCheckingUsername" class="checking">
Checking availability... ⏳
</span>

<!-- Available -->
<span *ngIf="usernameAvailable === true" class="available">
✅ Username is available!
</span>

<!-- Taken -->
<span *ngIf="usernameAvailable === false" class="taken">
❌ Username is already taken
</span>

<!-- Validation errors -->
<span *ngIf="registerForm.get('username')?.errors?.['required'] &&
registerForm.get('username')?.touched">
Username is required
</span>
<span *ngIf="registerForm.get('username')?.errors?.['minlength']">
At least 3 characters required
</span>
</div>

<div class="field">
<label>Email</label>
<input formControlName="email" type="email" placeholder="Enter email" />
<span *ngIf="registerForm.get('email')?.errors?.['email'] &&
registerForm.get('email')?.touched">
Invalid email address
</span>
</div>

<div class="field">
<label>Password</label>
<input formControlName="password" type="password" placeholder="Password" />
<div class="password-strength" [class]="passwordStrength">
{{ passwordStrengthLabel }}
</div>
</div>

<div class="field">
<label>Confirm Password</label>
<input formControlName="confirmPassword" type="password" />
<span *ngIf="registerForm.errors?.['passwordMismatch'] &&
registerForm.get('confirmPassword')?.touched">
Passwords do not match
</span>
</div>

<button type="submit" [disabled]="registerForm.invalid || isCheckingUsername">
Create Account
</button>

</form>
`

})
export class RegisterComponent implements OnInit, OnDestroy {

registerForm!: FormGroup;
isCheckingUsername = false;
usernameAvailable: boolean | null = null;
passwordStrength = 'weak';
passwordStrengthLabel = '';

private destroy$ = new Subject<void>();

constructor(
private fb: FormBuilder,
private authService: AuthService
) {}

ngOnInit(): void {
this.registerForm = this.fb.group({
username: ['', [Validators.required, Validators.minLength(3)]],
email: ['', [Validators.required, Validators.email]],
password: ['', [Validators.required, Validators.minLength(8)]],
confirmPassword: ['', Validators.required]
}, {
validators: this.passwordMatchValidator
});

// --- RxJS Magic: Username availability check ---
this.registerForm.get('username')!.valueChanges
.pipe(
debounceTime(500), // Wait 500ms after typing
distinctUntilChanged(), // Don't check if same value
takeUntil(this.destroy$)
)
.subscribe(username => {
if (username && username.length >= 3) {
this.isCheckingUsername = true;
this.usernameAvailable = null;

this.authService.checkUsername(username)
.pipe(takeUntil(this.destroy$))
.subscribe({
next: (isAvailable) => {
this.usernameAvailable = isAvailable;
this.isCheckingUsername = false;
},
error: () => {
this.isCheckingUsername = false;
}
});
} else {
this.usernameAvailable = null;
}
});

// --- RxJS Magic: Password strength meter ---
this.registerForm.get('password')!.valueChanges
.pipe(takeUntil(this.destroy$))
.subscribe(password => {
this.updatePasswordStrength(password || '');
});
}

private updatePasswordStrength(password: string): void {
let score = 0;
if (password.length >= 8) score++;
if (/[A-Z]/.test(password)) score++;
if (/[0-9]/.test(password)) score++;
if (/[^A-Za-z0-9]/.test(password)) score++;

if (score <= 1) {
this.passwordStrength = 'weak';
this.passwordStrengthLabel = '🔴 Weak';
} else if (score === 2) {
this.passwordStrength = 'fair';
this.passwordStrengthLabel = '🟡 Fair';
} else if (score === 3) {
this.passwordStrength = 'good';
this.passwordStrengthLabel = '🟢 Good';
} else {
this.passwordStrength = 'strong';
this.passwordStrengthLabel = '💪 Strong';
}
}

private passwordMatchValidator(group: AbstractControl) {
const password = group.get('password')?.value;
const confirm = group.get('confirmPassword')?.value;
return password === confirm ? null : { passwordMismatch: true };
}

onSubmit(): void {
if (this.registerForm.valid && this.usernameAvailable) {
console.log('Register:', this.registerForm.value);
}
}

ngOnDestroy(): void {
this.destroy$.next();
this.destroy$.complete();
}
}












🏙️ Real Example 2 — Dependent Dropdowns (Country → City)



When selecting a country should dynamically load cities for that country:




@Component({
template: `
<form [formGroup]="addressForm">

<select formControlName="country">
<option value="">Select Country</option>
<option *ngFor="let c of countries" [value]="c.code">
{{ c.name }}
</option>
</select>

<select formControlName="city">
<option value="">
{{ isLoadingCities ? 'Loading cities...' : 'Select City' }}
</option>
<option *ngFor="let city of cities" [value]="city.id">
{{ city.name }}
</option>
</select>

</form>
`

})
export class AddressFormComponent implements OnInit, OnDestroy {

addressForm = this.fb.group({
country: [''],
city: [{ value: '', disabled: true }]
});

countries = [
{ code: 'BD', name: 'Bangladesh' },
{ code: 'IN', name: 'India' },
{ code: 'US', name: 'USA' }
];

cities: any[] = [];
isLoadingCities = false;

private destroy$ = new Subject<void>();

constructor(
private fb: FormBuilder,
private locationService: LocationService
) {}

ngOnInit(): void {

// When country changes — load its cities
this.addressForm.get('country')!.valueChanges
.pipe(
takeUntil(this.destroy$),
tap(() => {
// Reset city when country changes
this.cities = [];
this.addressForm.get('city')!.disable();
this.addressForm.get('city')!.setValue('');
this.isLoadingCities = true;
}),
switchMap(countryCode => {
if (!countryCode) return of([]);
return this.locationService.getCitiesByCountry(countryCode)
.pipe(catchError(() => of([])));
})
)
.subscribe(cities => {
this.cities = cities;
this.isLoadingCities = false;
if (cities.length > 0) {
this.addressForm.get('city')!.enable();
}
});
}

ngOnDestroy(): void {
this.destroy$.next();
this.destroy$.complete();
}
}






When the country changes, the city dropdown automatically:




  1. Resets to empty

  2. Shows "Loading cities..."

  3. Disables itself

  4. Loads new cities from API

  5. Re-enables with new options



All powered by valueChanges + switchMap!









💰 Real Example 3 — Live Price Calculator



A checkout form where the price updates as you change quantity and select options:




@Component({
template: `
<form [formGroup]="orderForm">
<label>Quantity</label>
<input type="number" formControlName="quantity" min="1">

<label>Size</label>
<select formControlName="size">
<option value="small">Small</option>
<option value="medium">Medium (+৳200)</option>
<option value="large">Large (+৳400)</option>
</select>

<label>
<input type="checkbox" formControlName="giftWrap">
Gift Wrap (+৳50)
</label>

<div class="price-summary">
<p>Base price: ৳{{ basePrice }}</p>
<p>Total: <strong>৳{{ liveTotal$ | async }}</strong></p>
</div>
</form>
`

})
export class OrderFormComponent implements OnInit {

basePrice = 500;

orderForm = this.fb.group({
quantity: [1],
size: ['small'],
giftWrap: [false]
});

liveTotal$!: Observable<number>;

constructor(private fb: FormBuilder) {}

ngOnInit(): void {
const sizeAddon: Record<string, number> = {
small: 0,
medium: 200,
large: 400
};

// Calculate total every time ANY field changes
this.liveTotal$ = this.orderForm.valueChanges.pipe(
startWith(this.orderForm.value),
map(values => {
const qty = values.quantity || 1;
const sizeExtra = sizeAddon[values.size] || 0;
const giftExtra = values.giftWrap ? 50 : 0;
return (this.basePrice + sizeExtra + giftExtra) * qty;
})
);
}
}






The total updates instantly as the user changes any field — no button, no event handlers, just pure reactive magic!









🔧 Using statusChanges for Async Validators






ngOnInit(): void {
// React to form validity changes
this.registerForm.statusChanges
.pipe(
distinctUntilChanged(),
takeUntil(this.destroy$)
)
.subscribe(status => {
// 'VALID', 'INVALID', 'PENDING', 'DISABLED'
if (status === 'VALID') {
this.canSubmit = true;
this.showSuccessHint = true;
} else {
this.canSubmit = false;
this.showSuccessHint = false;
}
});
}












🧠 Chapter 8 Summary — What You Learned





  • FormControl.valueChanges is an Observable — you can use all RxJS operators on it


  • FormControl.statusChanges tells you when validity changes

  • Use debounceTime + switchMap for async validation (username check, email uniqueness)

  • Use valueChanges + switchMap for dependent dropdowns (country → city)

  • Use valueChanges + map + startWith for live price calculators and previews

  • Always clean up form subscriptions with takeUntil or async pipe









📚 Coming Up in Chapter 9...



Chapter 9 covers debounceTime, throttleTime, distinctUntilChanged — the timing operators.



These are essential for search boxes, scroll events, resize events, and any situation where you need to control HOW OFTEN your code runs.



See you in Chapter 9! 🚀






💌 RxJS Deep Dive Newsletter Series | Chapter 8 of 10

Follow me on : Github Linkedin Threads Youtube Channel

Information ergänzen Fachhinweis, Update, Korrektur oder Quelle zur Meldung beitragen
Gäste-Hinweise werden kurz redaktionell geprüft und danach hier angezeigt.

Community-Hinweise zur Meldung

0 freigegeben
Social ReaktionenReagiere als Erste:r — dein Feedback zählt!
Informations-Bewertung:

💬 Debate de la comunidad y comentarios

🌐 Unirse al chat principal

Inicia el debate en el stream de difusión del Social Chat o envía arriba una contribución experta mediante el formulario de ampliación.

Valoración de la comunidad &amp; prueba social
⭐ Valoración de los lectores
–
Ø / 5.0
Aún no hay valoraciones de lectores
¿Le ha resultado útil este artículo?
0
Dejar una valoración ahora
Valoración detallada (opcional)
Contenido & calidad
Fuente & credibilidad
Actualidad
Briefing de seguridad Gratis · baja en 1 clic

Intelligence Digest — gratis

Cada día las noticias de seguridad más importantes · baja en cualquier momento

Clústeres de historias relacionados & fuentes (IA vectorial)

2 Cluster
2 fuentes
OpenAI counter-sues Apple over trade secret theft
AppleInsider News hace 3 h
1 fuente más
Artículos similares
🔍 Verwandte News

Auch interessante Nachrichten RxJS in Angular — Chapter 8 | RxJS + Angular Reactive Forms — Live Validation ও Dynamic Forms

Thematisch verwandte Begriffe: RxJS, Angular, Chapter, Reactive · 6 Treffer

Laden...

Cargando artículos ...

Laden...

Cargando vídeos ...

Laden...

Cargando artículos ...

Laden...

Cargando vídeos ...

Laden...

Cargando artículos ...

Laden...

Cargando vídeos ...

Laden...

Cargando artículos ...

Laden...

Cargando vídeos ...

💬 Cargando comentarios…
Desliza para actualizar
Widgets & Topics
Loading widgets…
Nächster Beitrag