Skip to content

Instantly share code, notes, and snippets.

@arun12209
Created January 21, 2023 07:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arun12209/bf83cb5520993511e8b9e7558205644f to your computer and use it in GitHub Desktop.
Save arun12209/bf83cb5520993511e8b9e7558205644f to your computer and use it in GitHub Desktop.
import { LightningElement, track, wire } from 'lwc';
import validateData from '@salesforce/apex/ValidationController.validateData';
export default class MyComponent extends LightningElement {
@track name;
@track email;
@track age;
@track errors = [];
handleSubmit() {
validateData({ name: this.name, email: this.email, age: this.age })
.then(result => {
if (result.errors.length > 0) {
this.errors = result.errors;
} else {
// proceed with next step in process
}
})
.catch(error => {
console.error(error);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment