Skip to content

Instantly share code, notes, and snippets.

View activebiz's full-sized avatar

Preyash Desai activebiz

  • United Kingdom, India
View GitHub Profile
@activebiz
activebiz / BootstrapV3DatetimePicker.d.ts
Last active December 15, 2015 09:57
Using bootstrap datetimepicker in aurelia (element) using typescript
/**
* Extension Types for the BootstrapV3DatetimePicker tsd files
* Thanks to : https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/bootstrap.v3.datetimepicker
*/
/// <reference path="../../jquery/jquery.d.ts"/>
/// <reference path="../../moment/moment.d.ts"/>
declare module BootstrapV3DatetimePicker {
interface DatetimepickerChangeEventObject extends DatetimepickerEventObject {
@activebiz
activebiz / gulpfile.js
Last active January 31, 2016 16:52
VSCode & Chrome debugger (Plugin) with typescript.
gulp.task('tscompile', function (done) {
return gulp.src('app/**/*.ts')
.pipe(sourcemaps.init())
.pipe(ts({
target: "es5",
module: "system",
emitDecoratorMetadata: true,
experimentalDecorators: true
})).js
.pipe(sourcemaps.write('.',{ includeContent: true, sourceRoot: "/" }))
<template>
<form submit.delegate="submit()">
<!--<ul><li repeat.for="error of controller.errors">${error.message}</li></ul>-->
<div class="form-group">
<label class="control-label" for="first">First Name</label>
<input type="text" class="form-control" id="first" placeholder="First Name"
value.bind="firstName & validate">
</div>
<template>
<h1>${message}</h1>
<input value.bind="myText"/>
</template>
@activebiz
activebiz / app.html
Created March 12, 2017 09:11 — forked from ScottWhittaker/app.html
Aurelia Router Demo
<template>
<require from="components/navigation.html"></require>
<h1>Aurelia Router Demo</h1>
<navigation router.bind="router" class="primary-navigation"></navigation>
<div class="page-host">
<router-view></router-view>
</div>
</template>
public interface IMyValidator<T, V> : IValidator<T>
{
}
internal class MyInputTypeValidator : AbstractValidator<MyModel>, IMyValidator<MyModel, MyInputTypeValidator>
{
public MyInputTypeValidator(IMyService myService)
{
… // validation rules
}
}
public class MyValidationMiddleware<T, V>
{
private readonly FieldDelegate _next;
private readonly IMyValidator<T, V> _validator;
public MyValidationMiddleware(FieldDelegate next, IMyValidator<T, V> validator)
{
_next = next;
_validator = validator;
}
internal static class MyValidationMiddlewareFieldExtensions
{
public static IObjectFieldDescriptor UseValidator<T, V>(this IObjectFieldDescriptor descriptor)
where V : AbstractValidator<T>
{
return descriptor.Use<MyValidationMiddleware<T, V>>();
}
}
protected override void Configure(IObjectTypeDescriptor descriptor)
{
descriptor.Field<MyField>(f => f.CreateModel(default))
.Argument("input", a => a.Type<NonNullType<MyInputType>>())
.UseValidator<MyModel, MyInputTypeValidator>()
.Type<NonNullType<MyModelResult>>();
}