Hi! I'm Joshua. I build things with JavaScript.
I'm passionate about:
🧑💻 Developer Experience
💅 Design Language Systems
🌎 Distributed Systems
⚙️ Software Development Processes
⌨️ Making Angular 1 forms suck less.
License: Do What The F*ck You Want To Public License
In an address form, a developer may be doing validation to check that a user's postal code is valid for the state/province they have selected. The developer would like to tailor the validation error message for the postal code field to say something like, "Please enter a valid zip code for California."
This requires that the ngMessage copy be dynamic.
Allow developers to pass either a string literal or a function when defining error messages:
vm.controls = {
postalCode: {
errors: [
// Static error copy.
['required', 'This field is required.'],
// Dynamic error copy.
['pattern', () => {
const state = vm.addressForm.getModelValues().state;
return `Please enter a valid postal code for ${state}.`;
}]
]
}
}
This approach would allow a developer to use any data in the context of the form's parent controller's closure to compute the copy for the error message. The downside, however, is that these definitions now become very tightly-coupled to the specific form in which they are being used; the error message function is making an assumption about control names in the form. This makes dynamic definitions less share-able and less reusable.
One way to combat this could be to ensure that these functions have fallbacks if their assumptions are false:
vm.controls = {
postalCode: {
errors: [
// Static error copy.
['required', 'This field is required.'],
// Dynamic error copy.
['pattern', () => {
const state = vm.addressForm.getModelValues().state;
if (state) {
return `Please enter a valid postal code for ${state}.`;
} else {
// Form doesn't have a control named "state", or the
// state control has a falsy model value.
return 'Please enter a valid postal code.';
}
}]
]
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.