Socket
Socket
Sign inDemoInstall

@glimmer/validator

Package Overview
Dependencies
2
Maintainers
12
Versions
140
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@glimmer/validator


Version published
Maintainers
12
Install size
603 kB
Created

Package description

What is @glimmer/validator?

@glimmer/validator is a package used in the Glimmer.js ecosystem to provide reactive state management and validation. It allows developers to create reactive properties and track changes to them, ensuring that the UI stays in sync with the underlying data model.

What are @glimmer/validator's main functionalities?

Tracking Changes

This feature allows you to track changes to properties. When a tracked property changes, any dependent properties or computations are automatically updated.

const { tracked } = require('@glimmer/validator');

class Person {
  @tracked firstName;
  @tracked lastName;

  constructor(firstName, lastName) {
    this.firstName = firstName;
    this.lastName = lastName;
  }

  get fullName() {
    return `${this.firstName} ${this.lastName}`;
  }
}

let person = new Person('John', 'Doe');
console.log(person.fullName); // John Doe
person.firstName = 'Jane';
console.log(person.fullName); // Jane Doe

Validation

This feature allows you to validate properties using custom logic. The `@validate` decorator can be used to create computed properties that validate the state of other properties.

const { tracked, validate } = require('@glimmer/validator');

class User {
  @tracked email;

  constructor(email) {
    this.email = email;
  }

  @validate
  get isValidEmail() {
    return /^[^@]+@[^@]+\.[^@]+$/.test(this.email);
  }
}

let user = new User('test@example.com');
console.log(user.isValidEmail); // true
user.email = 'invalid-email';
console.log(user.isValidEmail); // false

Other packages similar to @glimmer/validator

Changelog

Source

v0.79.1 (2021-05-11)

:bug: Bug Fix
  • @glimmer/runtime
    • #1304 Remove unnecessary property descriptor assertion from hash (@pzuraq)
Committers: 1

FAQs

Last updated on 11 May 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc