![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
ember-lgtm
Advanced tools
This ember-cli addon provides a Mixin around Square's LGTM Validation library. The mixin follows recommended validation patterns. This addon also adds a few LGTM helpers to add support for nested validation and registers LGTM to use Ember's RSVP
ember install ember-lgtm
In your component or model class, where you will add your validation, simply include the Validatable Mixin and provide a validator object. See the example below:
import LGTM from 'lgtm';
import Validatable from 'ember-lgtm/mixins/validatable';
Ember.Component.extend(Validatable, {
validator: LGTM.validator()
.validates('email') // Name of your property
.required('Email address is required')
.email('Enter a valid email')
.build(),
actions: {
save() {
this.validate().then(isValid => {
if (isValid) {
// Perform the actual save
}
})
}
}
// Other code...
});
Then in your template, you have access to an errors array for each validated property.
<label>Email:</label>
{{input value=email class=(if errors.email "error")}}
<span class="error">{{errors.email}}</span>
<button onclick={{action "save"}}>Save</button>
When the properties are in an valid state (initial), the validation won't be triggered. This leads to a better UX since the user doesn't want to see errors while he's in the middle of typing something that will likely turn something from invalid to valid. However, if a property is already in an invalid state, it will be re-validated when the property changes. This is also known as inline validation and is useful to provide immediate feedback when somethings goes from invalid to valid.
ember-lgtm also adds two LGTM helpers to add support for nested validations for objects and arrays.
Validates a validatable object. A validatable object is anything with a validate
function returning a boolean promise (like the mixin mixin/validatable)
In this example, the property billingAddress
contains an address object that implements a validate
function to validate the individual properties of the address. The parent object only checks the overall validity of the object, rather than each individual field.
validator: LGTM.validator()
.validates('fullName')
.required('Full name is required')
.validates('billingAddress')
.isValid()
.build()
Validates all validatable objects in the array are valid. A validatable object is anything with a validate
function returning a boolean promise (like the mixin mixin/validatable).
This functions like isValid
, except that the validated property should be an array of validatable objects, which must all be valid in order for this validator function to return true.
validator: LGTM.validator()
.validates('arrayOfAddresses')
.allAreValid()
.build()
You can create your own Custom Helpers by using LGTM.helpers.register
directly.
LGTM uses Promises and this addon configures it to use the same RSVP library that Ember uses. When doing server side validation, the validate
function returns a Promise and each validation registered either return immediately or return a promise. LGTM will execute all the promises in parallel and wait for all the validation logic to complete before returning the validation information.
LGTM is a simple JavaScript library for validating objects and collecting error messages. It leaves the display, behavior, and error messages in your hands, focusing on letting you describe your validations cleanly and concisely for whatever environment you're using.
You can find more about it on the LGTM Wiki that includes an API Reference and information about how to create Custom Helpers
git clone https://github.com/practicefusion/ember-lgtm
yarn
ember server
ember test
ember test --server
For more information on using ember-cli, visit http://www.ember-cli.com/.
FAQs
Ember CLI addon for Square's LGTM validation library
The npm package ember-lgtm receives a total of 8 weekly downloads. As such, ember-lgtm popularity was classified as not popular.
We found that ember-lgtm demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.